<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>map - Vim Documentation</title>
<meta name="Generator" content="Vim/8.0">
<meta name="plugin-version" content="vim8.0">
<meta name="syntax" content="help">
<meta name="settings" content="no_pre,use_css,expand_tabs">
<link rel="stylesheet" href="style.css" type="text/css" />

<script src="jquery.min.js" type="text/javascript"></script>
<script src="mark-current-page.js" type="text/javascript"></script>
</head>

<body>

<header>

<div class="header">
  <a href="http://vim-jp.org/">vim-jp</a>
  / <a href="http://vim-jp.org/vimdoc-en/">vimdoc-en</a>
  / map<br />
  <a name="top"></a><h1>map - Vim Documentation</h1>
  <a href="index.html">Return to main</a>

  <span class="EnglishJapaneseLink">
    <span class="CurrentLanguage">English</span>
  </span>
</div>
</header>

<nav>
<dl>

<dt>BASIC</dt>
<dd><ul>
<li><a href="quickref.html">quickref</a></li>
<li><a href="sponsor.html">sponsor</a></li>
</ul></dd>

<dt>USER MANUAL</dt>
<dd><ul>
<li><a href="usr_toc.html">usr_toc</a></li>
</ul></dd>

<dt>Getting Started</dt>
<dd><ul>
<li><a href="usr_01.html">usr_01</a></li>
<li><a href="usr_02.html">usr_02</a></li>
<li><a href="usr_03.html">usr_03</a></li>
<li><a href="usr_04.html">usr_04</a></li>
<li><a href="usr_05.html">usr_05</a></li>
<li><a href="usr_06.html">usr_06</a></li>
<li><a href="usr_07.html">usr_07</a></li>
<li><a href="usr_08.html">usr_08</a></li>
<li><a href="usr_09.html">usr_09</a></li>
<li><a href="usr_10.html">usr_10</a></li>
<li><a href="usr_11.html">usr_11</a></li>
<li><a href="usr_12.html">usr_12</a></li>
</ul></dd>

<dt>Editing Effectively</dt>
<dd><ul>
<li><a href="usr_20.html">usr_20</a></li>
<li><a href="usr_21.html">usr_21</a></li>
<li><a href="usr_22.html">usr_22</a></li>
<li><a href="usr_23.html">usr_23</a></li>
<li><a href="usr_24.html">usr_24</a></li>
<li><a href="usr_25.html">usr_25</a></li>
<li><a href="usr_26.html">usr_26</a></li>
<li><a href="usr_27.html">usr_27</a></li>
<li><a href="usr_28.html">usr_28</a></li>
<li><a href="usr_29.html">usr_29</a></li>
<li><a href="usr_30.html">usr_30</a></li>
<li><a href="usr_31.html">usr_31</a></li>
<li><a href="usr_32.html">usr_32</a></li>
</ul></dd>

<dt>Tuning Vim</dt>
<dd><ul>
<li><a href="usr_40.html">usr_40</a></li>
<li><a href="usr_41.html">usr_41</a></li>
<li><a href="usr_42.html">usr_42</a></li>
<li><a href="usr_43.html">usr_43</a></li>
<li><a href="usr_44.html">usr_44</a></li>
<li><a href="usr_45.html">usr_45</a></li>
</ul></dd>

<dt>Making Vim Run</dt>
<dd><ul>
<li><a href="usr_90.html">usr_90</a></li>
</ul></dd>

<dt>General subjects</dt>
<dd><ul>
<li><a href="intro.html">intro</a></li>
<li><a href="index.html">help</a></li>
<li><a href="helphelp.html">helphelp</a></li>
<li><a href="vimindex.html">index</a></li>
<li><a href="tags.html">tags</a></li>
<li><a href="howto.html">howto</a></li>
<li><a href="tips.html">tips</a></li>
<li><a href="message.html">message</a></li>
<li><a href="quotes.html">quotes</a></li>
<li><a href="todo.html">todo</a></li>
<li><a href="debug.html">debug</a></li>
<li><a href="develop.html">develop</a></li>
<li><a href="uganda.html">uganda</a></li>
</ul></dd>

<dt>Basic editing</dt>
<dd><ul>
<li><a href="starting.html">starting</a></li>
<li><a href="editing.html">editing</a></li>
<li><a href="motion.html">motion</a></li>
<li><a href="scroll.html">scroll</a></li>
<li><a href="insert.html">insert</a></li>
<li><a href="change.html">change</a></li>
<li><a href="indent.html">indent</a></li>
<li><a href="undo.html">undo</a></li>
<li><a href="repeat.html">repeat</a></li>
<li><a href="visual.html">visual</a></li>
<li><a href="various.html">various</a></li>
<li><a href="recover.html">recover</a></li>
</ul></dd>

<dt>Advanced editing</dt>
<dd><ul>
<li><a href="cmdline.html">cmdline</a></li>
<li><a href="options.html">options</a></li>
<li><a href="pattern.html">pattern</a></li>
<li><a href="map.html">map</a></li>
<li><a href="tagsrch.html">tagsrch</a></li>
<li><a href="quickfix.html">quickfix</a></li>
<li><a href="windows.html">windows</a></li>
<li><a href="tabpage.html">tabpage</a></li>
<li><a href="syntax.html">syntax</a></li>
<li><a href="spell.html">spell</a></li>
<li><a href="diff.html">diff</a></li>
<li><a href="autocmd.html">autocmd</a></li>
<li><a href="filetype.html">filetype</a></li>
<li><a href="eval.html">eval</a></li>
<li><a href="channel.html">channel</a></li>
<li><a href="fold.html">fold</a></li>
</ul></dd>

<dt>Special issues</dt>
<dd><ul>
<li><a href="print.html">print</a></li>
<li><a href="remote.html">remote</a></li>
<li><a href="term.html">term</a></li>
<li><a href="digraph.html">digraph</a></li>
<li><a href="mbyte.html">mbyte</a></li>
<li><a href="mlang.html">mlang</a></li>
<li><a href="arabic.html">arabic</a></li>
<li><a href="farsi.html">farsi</a></li>
<li><a href="hebrew.html">hebrew</a></li>
<li><a href="russian.html">russian</a></li>
<li><a href="ft_ada.html">ft_ada</a></li>
<li><a href="ft_sql.html">ft_sql</a></li>
<li><a href="hangulin.html">hangulin</a></li>
<li><a href="rileft.html">rileft</a></li>
</ul></dd>

<dt>GUI</dt>
<dd><ul>
<li><a href="gui.html">gui</a></li>
<li><a href="gui_w32.html">gui_w32</a></li>
<li><a href="gui_x11.html">gui_x11</a></li>
</ul></dd>

<dt>Interfaces</dt>
<dd><ul>
<li><a href="if_cscop.html">if_cscop</a></li>
<li><a href="if_lua.html">if_lua</a></li>
<li><a href="if_mzsch.html">if_mzsch</a></li>
<li><a href="if_perl.html">if_perl</a></li>
<li><a href="if_pyth.html">if_pyth</a></li>
<li><a href="if_tcl.html">if_tcl</a></li>
<li><a href="if_ole.html">if_ole</a></li>
<li><a href="if_ruby.html">if_ruby</a></li>
<li><a href="debugger.html">debugger</a></li>
<li><a href="workshop.html">workshop</a></li>
<li><a href="netbeans.html">netbeans</a></li>
<li><a href="sign.html">sign</a></li>
</ul></dd>

<dt>Versions</dt>
<dd><ul>
<li><a href="vi_diff.html">vi_diff</a></li>
<li><a href="version4.html">version4</a></li>
<li><a href="version5.html">version5</a></li>
<li><a href="version6.html">version6</a></li>
<li><a href="version7.html">version7</a></li>
<li><a href="version8.html">version8</a></li>
</ul></dd>

<dt>Remarks about specific systems</dt>
<dd><ul>
<li><a href="os_390.html">os_390</a></li>
<li><a href="os_amiga.html">os_amiga</a></li>
<li><a href="os_beos.html">os_beos</a></li>
<li><a href="os_dos.html">os_dos</a></li>
<li><a href="os_mac.html">os_mac</a></li>
<li><a href="os_mint.html">os_mint</a></li>
<li><a href="os_msdos.html">os_msdos</a></li>
<li><a href="os_os2.html">os_os2</a></li>
<li><a href="os_qnx.html">os_qnx</a></li>
<li><a href="os_risc.html">os_risc</a></li>
<li><a href="os_unix.html">os_unix</a></li>
<li><a href="os_vms.html">os_vms</a></li>
<li><a href="os_win32.html">os_win32</a></li>
</ul></dd>

<dt>Standard plugins</dt>
<dd><ul>
<li><a href="pi_getscript.html">pi_getscript</a></li>
<li><a href="pi_gzip.html">pi_gzip</a></li>
<li><a href="pi_logipat.html">pi_logipat</a></li>
<li><a href="pi_netrw.html">pi_netrw</a></li>
<li><a href="pi_paren.html">pi_paren</a></li>
<li><a href="pi_tar.html">pi_tar</a></li>
<li><a href="pi_vimball.html">pi_vimball</a></li>
<li><a href="pi_zip.html">pi_zip</a></li>
</ul></dd>

<dt>Filetype plugins</dt>
<dd><ul>
<li><a href="pi_spec.html">pi_spec</a></li>
</ul></dd>

<dt>Others</dt>
<dd><ul>
<li><a href="vim_faq.html">vim_faq</a></li>
</ul></dd>

</dl>
</nav>

<article class="Vimdoc VimdocJa">
<div id='vimCodeElement'>
<a class="Constant" href="map.html" name="map.txt">map.txt</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; For&nbsp;<span class="Identifier">Vim version 8.0.</span>&nbsp;&nbsp;Last change: 2017 May 30<br>
<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="Identifier">VIM REFERENCE MANUAL&nbsp;&nbsp;&nbsp;&nbsp;by Bram Moolenaar</span><br>
<br>
<br>
Key mapping, abbreviations and user-defined commands.<br>
<br>
This subject is introduced in sections&nbsp;<a class="Identifier" href="usr_05.html#05.3">05.3</a>,&nbsp;<a class="Identifier" href="usr_24.html#24.7">24.7</a>&nbsp;and&nbsp;<a class="Identifier" href="usr_40.html#40.1">40.1</a>&nbsp;of the user<br>
manual.<br>
<br>
1. Key mapping&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#key-mapping">key-mapping</a><br>
&nbsp;&nbsp; 1.1 MAP COMMANDS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#:map-commands">:map-commands</a><br>
&nbsp;&nbsp; 1.2 Special arguments&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#:map-arguments">:map-arguments</a><br>
&nbsp;&nbsp; 1.3 Mapping and modes&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#:map-modes">:map-modes</a><br>
&nbsp;&nbsp; 1.4 Listing mappings&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#map-listing">map-listing</a><br>
&nbsp;&nbsp; 1.5 Mapping special keys&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#:map-special-keys">:map-special-keys</a><br>
&nbsp;&nbsp; 1.6 Special characters&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#:map-special-chars">:map-special-chars</a><br>
&nbsp;&nbsp; 1.7 What keys to map&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#map-which-keys">map-which-keys</a><br>
&nbsp;&nbsp; 1.8 Examples&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#map-examples">map-examples</a><br>
&nbsp;&nbsp; 1.9 Using mappings&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#map-typing">map-typing</a><br>
&nbsp;&nbsp; 1.10 Mapping alt-keys&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#:map-alt-keys">:map-alt-keys</a><br>
&nbsp;&nbsp; 1.11 Mapping an operator&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#:map-operator">:map-operator</a><br>
2. Abbreviations&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#abbreviations">abbreviations</a><br>
3. Local mappings and functions&nbsp;<a class="Identifier" href="map.html#script-local">script-local</a><br>
4. User-defined commands&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#user-commands">user-commands</a><br>
<br>
<span class="PreProc">==============================================================================</span><br>
1. Key mapping&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#key-mapping" name="key-mapping">key-mapping</a>&nbsp;<a class="Constant" href="map.html#mapping" name="mapping">mapping</a>&nbsp;<a class="Constant" href="map.html#macro" name="macro">macro</a><br>
<br>
Key mapping is used to change the meaning of typed keys.&nbsp;&nbsp;The most common use<br>
is to define a sequence commands for a function key.&nbsp;&nbsp;Example:<br>
<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:map &lt;F2&gt; a&lt;C-R&gt;=strftime(&quot;%c&quot;)&lt;CR&gt;&lt;Esc&gt;</div>
<br>
This appends the current date and time after the cursor (in &lt;&gt; notation&nbsp;<a class="Identifier" href="intro.html#<>">&lt;&gt;</a>).<br>
<br>
<br>
1.1 MAP COMMANDS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:map-commands" name=":map-commands">:map-commands</a><br>
<br>
There are commands to enter new mappings, remove mappings and list mappings.<br>
See&nbsp;<a class="Identifier" href="map.html#map-overview">map-overview</a>&nbsp;for the various forms of &quot;map&quot; and their relationships with<br>
modes.<br>
<br>
<span class="Special">{lhs}</span>&nbsp;&nbsp; means left-hand-side&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#{lhs}" name="{lhs}">{lhs}</a><br>
<span class="Special">{rhs}</span>&nbsp;&nbsp; means right-hand-side&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#{rhs}" name="{rhs}">{rhs}</a><br>
<br>
:map&nbsp;&nbsp;&nbsp;&nbsp;<span class="Special">{lhs}</span>&nbsp;<span class="Special">{rhs}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-nvo">mapmode-nvo</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:map" name=":map">:map</a><br>
:nm[ap]&nbsp;<span class="Special">{lhs}</span>&nbsp;<span class="Special">{rhs}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-n">mapmode-n</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:nm" name=":nm">:nm</a>&nbsp;<a class="Constant" href="map.html#:nmap" name=":nmap">:nmap</a><br>
:vm[ap]&nbsp;<span class="Special">{lhs}</span>&nbsp;<span class="Special">{rhs}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-v">mapmode-v</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:vm" name=":vm">:vm</a>&nbsp;<a class="Constant" href="map.html#:vmap" name=":vmap">:vmap</a><br>
:xm[ap]&nbsp;<span class="Special">{lhs}</span>&nbsp;<span class="Special">{rhs}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-x">mapmode-x</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:xm" name=":xm">:xm</a>&nbsp;<a class="Constant" href="map.html#:xmap" name=":xmap">:xmap</a><br>
:smap&nbsp;&nbsp;&nbsp;<span class="Special">{lhs}</span>&nbsp;<span class="Special">{rhs}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-s">mapmode-s</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:smap" name=":smap">:smap</a><br>
:om[ap]&nbsp;<span class="Special">{lhs}</span>&nbsp;<span class="Special">{rhs}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-o">mapmode-o</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:om" name=":om">:om</a>&nbsp;<a class="Constant" href="map.html#:omap" name=":omap">:omap</a><br>
:map!&nbsp;&nbsp;&nbsp;<span class="Special">{lhs}</span>&nbsp;<span class="Special">{rhs}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-ic">mapmode-ic</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:map!" name=":map!">:map!</a><br>
:im[ap]&nbsp;<span class="Special">{lhs}</span>&nbsp;<span class="Special">{rhs}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-i">mapmode-i</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:im" name=":im">:im</a>&nbsp;<a class="Constant" href="map.html#:imap" name=":imap">:imap</a><br>
:lm[ap]&nbsp;<span class="Special">{lhs}</span>&nbsp;<span class="Special">{rhs}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-l">mapmode-l</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:lm" name=":lm">:lm</a>&nbsp;<a class="Constant" href="map.html#:lmap" name=":lmap">:lmap</a><br>
:cm[ap]&nbsp;<span class="Special">{lhs}</span>&nbsp;<span class="Special">{rhs}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-c">mapmode-c</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:cm" name=":cm">:cm</a>&nbsp;<a class="Constant" href="map.html#:cmap" name=":cmap">:cmap</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Map the key sequence&nbsp;<span class="Special">{lhs}</span>&nbsp;to&nbsp;<span class="Special">{rhs}</span>&nbsp;for the modes<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;where the map command applies.&nbsp;&nbsp;The result, including<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="Special">{rhs}</span>, is then further scanned for mappings.&nbsp;&nbsp;This<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;allows for nested and recursive use of mappings.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:nore" name=":nore">:nore</a>&nbsp;<a class="Constant" href="map.html#:norem" name=":norem">:norem</a><br>
:no[remap]&nbsp;&nbsp;<span class="Special">{lhs}</span>&nbsp;<span class="Special">{rhs}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-nvo">mapmode-nvo</a>&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:no" name=":no">:no</a>&nbsp;&nbsp;<a class="Constant" href="map.html#:noremap" name=":noremap">:noremap</a>&nbsp;<a class="Constant" href="map.html#:nor" name=":nor">:nor</a><br>
:nn[oremap]&nbsp;<span class="Special">{lhs}</span>&nbsp;<span class="Special">{rhs}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-n">mapmode-n</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:nn" name=":nn">:nn</a>&nbsp;&nbsp;<a class="Constant" href="map.html#:nnoremap" name=":nnoremap">:nnoremap</a><br>
:vn[oremap]&nbsp;<span class="Special">{lhs}</span>&nbsp;<span class="Special">{rhs}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-v">mapmode-v</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:vn" name=":vn">:vn</a>&nbsp;&nbsp;<a class="Constant" href="map.html#:vnoremap" name=":vnoremap">:vnoremap</a><br>
:xn[oremap]&nbsp;<span class="Special">{lhs}</span>&nbsp;<span class="Special">{rhs}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-x">mapmode-x</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:xn" name=":xn">:xn</a>&nbsp;&nbsp;<a class="Constant" href="map.html#:xnoremap" name=":xnoremap">:xnoremap</a><br>
:snor[emap]&nbsp;<span class="Special">{lhs}</span>&nbsp;<span class="Special">{rhs}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-s">mapmode-s</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:snor" name=":snor">:snor</a>&nbsp;<a class="Constant" href="map.html#:snoremap" name=":snoremap">:snoremap</a><br>
:ono[remap]&nbsp;<span class="Special">{lhs}</span>&nbsp;<span class="Special">{rhs}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-o">mapmode-o</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:ono" name=":ono">:ono</a>&nbsp;<a class="Constant" href="map.html#:onoremap" name=":onoremap">:onoremap</a><br>
:no[remap]!&nbsp;<span class="Special">{lhs}</span>&nbsp;<span class="Special">{rhs}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-ic">mapmode-ic</a>&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:no!" name=":no!">:no!</a>&nbsp;<a class="Constant" href="map.html#:noremap!" name=":noremap!">:noremap!</a><br>
:ino[remap]&nbsp;<span class="Special">{lhs}</span>&nbsp;<span class="Special">{rhs}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-i">mapmode-i</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:ino" name=":ino">:ino</a>&nbsp;<a class="Constant" href="map.html#:inoremap" name=":inoremap">:inoremap</a><br>
:ln[oremap]&nbsp;<span class="Special">{lhs}</span>&nbsp;<span class="Special">{rhs}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-l">mapmode-l</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:ln" name=":ln">:ln</a>&nbsp;&nbsp;<a class="Constant" href="map.html#:lnoremap" name=":lnoremap">:lnoremap</a><br>
:cno[remap]&nbsp;<span class="Special">{lhs}</span>&nbsp;<span class="Special">{rhs}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-c">mapmode-c</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:cno" name=":cno">:cno</a>&nbsp;<a class="Constant" href="map.html#:cnoremap" name=":cnoremap">:cnoremap</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Map the key sequence&nbsp;<span class="Special">{lhs}</span>&nbsp;to&nbsp;<span class="Special">{rhs}</span>&nbsp;for the modes<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;where the map command applies.&nbsp;&nbsp;Disallow mapping of<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="Special">{rhs}</span>, to avoid nested and recursive mappings.&nbsp;&nbsp;Often<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;used to redefine a command.&nbsp;&nbsp;<span class="Special">{not in Vi}</span><br>
<br>
<br>
:unm[ap]&nbsp;&nbsp;<span class="Special">{lhs}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-nvo">mapmode-nvo</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:unm" name=":unm">:unm</a>&nbsp;&nbsp;<a class="Constant" href="map.html#:unmap" name=":unmap">:unmap</a><br>
:nun[map]&nbsp;<span class="Special">{lhs}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-n">mapmode-n</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:nun" name=":nun">:nun</a>&nbsp;&nbsp;<a class="Constant" href="map.html#:nunmap" name=":nunmap">:nunmap</a><br>
:vu[nmap]&nbsp;<span class="Special">{lhs}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-v">mapmode-v</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:vu" name=":vu">:vu</a>&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:vunmap" name=":vunmap">:vunmap</a><br>
:xu[nmap]&nbsp;<span class="Special">{lhs}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-x">mapmode-x</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:xu" name=":xu">:xu</a>&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:xunmap" name=":xunmap">:xunmap</a><br>
:sunm[ap]&nbsp;<span class="Special">{lhs}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-s">mapmode-s</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:sunm" name=":sunm">:sunm</a>&nbsp;<a class="Constant" href="map.html#:sunmap" name=":sunmap">:sunmap</a><br>
:ou[nmap]&nbsp;<span class="Special">{lhs}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-o">mapmode-o</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:ou" name=":ou">:ou</a>&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:ounmap" name=":ounmap">:ounmap</a><br>
:unm[ap]!&nbsp;<span class="Special">{lhs}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-ic">mapmode-ic</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:unm!" name=":unm!">:unm!</a>&nbsp;<a class="Constant" href="map.html#:unmap!" name=":unmap!">:unmap!</a><br>
:iu[nmap]&nbsp;<span class="Special">{lhs}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-i">mapmode-i</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:iu" name=":iu">:iu</a>&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:iunmap" name=":iunmap">:iunmap</a><br>
:lu[nmap]&nbsp;<span class="Special">{lhs}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-l">mapmode-l</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:lu" name=":lu">:lu</a>&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:lunmap" name=":lunmap">:lunmap</a><br>
:cu[nmap]&nbsp;<span class="Special">{lhs}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-c">mapmode-c</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:cu" name=":cu">:cu</a>&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:cunmap" name=":cunmap">:cunmap</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Remove the mapping of&nbsp;<span class="Special">{lhs}</span>&nbsp;for the modes where the<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;map command applies.&nbsp;&nbsp;The mapping may remain defined<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for other modes where it applies.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="Todo">Note</span>: Trailing spaces are included in the&nbsp;<span class="Special">{lhs}</span>.&nbsp;&nbsp;This<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;unmap does NOT work:<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:map @@ foo<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:unmap @@ | print</div>
<br>
:mapc[lear]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-nvo">mapmode-nvo</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:mapc" name=":mapc">:mapc</a>&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:mapclear" name=":mapclear">:mapclear</a><br>
:nmapc[lear]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-n">mapmode-n</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:nmapc" name=":nmapc">:nmapc</a>&nbsp;&nbsp;<a class="Constant" href="map.html#:nmapclear" name=":nmapclear">:nmapclear</a><br>
:vmapc[lear]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-v">mapmode-v</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:vmapc" name=":vmapc">:vmapc</a>&nbsp;&nbsp;<a class="Constant" href="map.html#:vmapclear" name=":vmapclear">:vmapclear</a><br>
:xmapc[lear]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-x">mapmode-x</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:xmapc" name=":xmapc">:xmapc</a>&nbsp;&nbsp;<a class="Constant" href="map.html#:xmapclear" name=":xmapclear">:xmapclear</a><br>
:smapc[lear]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-s">mapmode-s</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:smapc" name=":smapc">:smapc</a>&nbsp;&nbsp;<a class="Constant" href="map.html#:smapclear" name=":smapclear">:smapclear</a><br>
:omapc[lear]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-o">mapmode-o</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:omapc" name=":omapc">:omapc</a>&nbsp;&nbsp;<a class="Constant" href="map.html#:omapclear" name=":omapclear">:omapclear</a><br>
:mapc[lear]!&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-ic">mapmode-ic</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:mapc!" name=":mapc!">:mapc!</a>&nbsp;&nbsp;<a class="Constant" href="map.html#:mapclear!" name=":mapclear!">:mapclear!</a><br>
:imapc[lear]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-i">mapmode-i</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:imapc" name=":imapc">:imapc</a>&nbsp;&nbsp;<a class="Constant" href="map.html#:imapclear" name=":imapclear">:imapclear</a><br>
:lmapc[lear]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-l">mapmode-l</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:lmapc" name=":lmapc">:lmapc</a>&nbsp;&nbsp;<a class="Constant" href="map.html#:lmapclear" name=":lmapclear">:lmapclear</a><br>
:cmapc[lear]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-c">mapmode-c</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:cmapc" name=":cmapc">:cmapc</a>&nbsp;&nbsp;<a class="Constant" href="map.html#:cmapclear" name=":cmapclear">:cmapclear</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Remove ALL mappings for the modes where the map<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;command applies.&nbsp;&nbsp;<span class="Special">{not in Vi}</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Use the&nbsp;<span class="Special">&lt;buffer&gt;</span>&nbsp;argument to remove buffer-local<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mappings&nbsp;<a class="Identifier" href="map.html#:map-<buffer>">:map-&lt;buffer&gt;</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Warning: This also removes the default mappings.<br>
<br>
:map&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-nvo">mapmode-nvo</a><br>
:nm[ap]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-n">mapmode-n</a><br>
:vm[ap]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-v">mapmode-v</a><br>
:xm[ap]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-x">mapmode-x</a><br>
:sm[ap]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-s">mapmode-s</a><br>
:om[ap]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-o">mapmode-o</a><br>
:map!&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-ic">mapmode-ic</a><br>
:im[ap]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-i">mapmode-i</a><br>
:lm[ap]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-l">mapmode-l</a><br>
:cm[ap]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-c">mapmode-c</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;List all key mappings for the modes where the map<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;command applies.&nbsp;&nbsp;<span class="Todo">Note</span>&nbsp;that &quot;:map&quot; and &quot;:map!&quot; are<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;used most often, because they include the other modes.<br>
<br>
:map&nbsp;&nbsp;&nbsp;&nbsp;<span class="Special">{lhs}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-nvo">mapmode-nvo</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:map_l" name=":map_l">:map_l</a><br>
:nm[ap]&nbsp;<span class="Special">{lhs}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-n">mapmode-n</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:nmap_l" name=":nmap_l">:nmap_l</a><br>
:vm[ap]&nbsp;<span class="Special">{lhs}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-v">mapmode-v</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:vmap_l" name=":vmap_l">:vmap_l</a><br>
:xm[ap]&nbsp;<span class="Special">{lhs}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-x">mapmode-x</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:xmap_l" name=":xmap_l">:xmap_l</a><br>
:sm[ap]&nbsp;<span class="Special">{lhs}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-s">mapmode-s</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:smap_l" name=":smap_l">:smap_l</a><br>
:om[ap]&nbsp;<span class="Special">{lhs}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-o">mapmode-o</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:omap_l" name=":omap_l">:omap_l</a><br>
:map!&nbsp;&nbsp;&nbsp;<span class="Special">{lhs}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-ic">mapmode-ic</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:map_l!" name=":map_l!">:map_l!</a><br>
:im[ap]&nbsp;<span class="Special">{lhs}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-i">mapmode-i</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:imap_l" name=":imap_l">:imap_l</a><br>
:lm[ap]&nbsp;<span class="Special">{lhs}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-l">mapmode-l</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:lmap_l" name=":lmap_l">:lmap_l</a><br>
:cm[ap]&nbsp;<span class="Special">{lhs}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="map.html#mapmode-c">mapmode-c</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:cmap_l" name=":cmap_l">:cmap_l</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;List the key mappings for the key sequences starting<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;with&nbsp;<span class="Special">{lhs}</span>&nbsp;in the modes where the map command applies.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="Special">{not in Vi}</span><br>
<br>
These commands are used to map a key or key sequence to a string of<br>
characters.&nbsp;&nbsp;You can use this to put command sequences under function keys,<br>
translate one key into another, etc.&nbsp;&nbsp;See&nbsp;<a class="Identifier" href="starting.html#:mkexrc">:mkexrc</a>&nbsp;for how to save and<br>
restore the current mappings.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#map-ambiguous" name="map-ambiguous">map-ambiguous</a><br>
When two mappings start with the same sequence of characters, they are<br>
ambiguous.&nbsp;&nbsp;Example:<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:imap aa foo<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:imap aaa bar</div>
When Vim has read &quot;aa&quot;, it will need to get another character to be able to<br>
decide if &quot;aa&quot; or &quot;aaa&quot; should be mapped.&nbsp;&nbsp;This means that after typing &quot;aa&quot;<br>
that mapping won't get expanded yet, Vim is waiting for another character.<br>
If you type a space, then &quot;foo&quot; will get inserted, plus the space.&nbsp;&nbsp;If you<br>
type &quot;a&quot;, then &quot;bar&quot; will get inserted.<br>
<span class="Special">{Vi does not allow ambiguous mappings}</span><br>
<br>
<br>
1.2 SPECIAL ARGUMENTS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:map-arguments" name=":map-arguments">:map-arguments</a><br>
<br>
&quot;<span class="Special">&lt;buffer&gt;</span>&quot;, &quot;<span class="Special">&lt;nowait&gt;</span>&quot;, &quot;<span class="Special">&lt;silent&gt;</span>&quot;, &quot;<span class="Special">&lt;special&gt;</span>&quot;, &quot;<span class="Special">&lt;script&gt;</span>&quot;, &quot;<span class="Special">&lt;expr&gt;</span>&quot; and<br>
&quot;<span class="Special">&lt;unique&gt;</span>&quot; can be used in any order.&nbsp;&nbsp;They must appear right after the<br>
command, before any other arguments.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:map-local" name=":map-local">:map-local</a>&nbsp;<a class="Constant" href="map.html#:map-<buffer>" name=":map-&lt;buffer&gt;">:map-&lt;buffer&gt;</a>&nbsp;<a class="Constant" href="map.html#E224" name="E224">E224</a>&nbsp;<a class="Constant" href="map.html#E225" name="E225">E225</a><br>
If the first argument to one of these commands is &quot;<span class="Special">&lt;buffer&gt;</span>&quot; the mapping will<br>
be effective in the current buffer only.&nbsp;&nbsp;Example:<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:map &lt;buffer&gt;&nbsp;&nbsp;,w&nbsp;&nbsp;/[.,;]&lt;CR&gt;</div>
Then you can map &quot;,w&quot; to something else in another buffer:<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:map &lt;buffer&gt;&nbsp;&nbsp;,w&nbsp;&nbsp;/[#&amp;!]&lt;CR&gt;</div>
The local buffer mappings are used before the global ones.&nbsp;&nbsp;See&nbsp;<span class="Special">&lt;nowait&gt;</span>&nbsp;below<br>
to make a short local mapping not taking effect when a longer global one<br>
exists.<br>
The &quot;<span class="Special">&lt;buffer&gt;</span>&quot; argument can also be used to clear mappings:<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:unmap &lt;buffer&gt; ,w<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:mapclear &lt;buffer&gt;</div>
Local mappings are also cleared when a buffer is deleted, but not when it is<br>
unloaded.&nbsp;&nbsp;Just like local option values.<br>
Also see&nbsp;<a class="Identifier" href="map.html#map-precedence">map-precedence</a>.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:map-<nowait>" name=":map-&lt;nowait&gt;">:map-&lt;nowait&gt;</a>&nbsp;<a class="Constant" href="map.html#:map-nowait" name=":map-nowait">:map-nowait</a><br>
When defining a buffer-local mapping for &quot;,&quot; there may be a global mapping<br>
that starts with &quot;,&quot;.&nbsp;&nbsp;Then you need to type another character for Vim to know<br>
whether to use the &quot;,&quot; mapping or the longer one.&nbsp;&nbsp;To avoid this add the<br>
<span class="Special">&lt;nowait&gt;</span>&nbsp;argument.&nbsp;&nbsp;Then the mapping will be used when it matches, Vim does<br>
not wait for more characters to be typed.&nbsp;&nbsp;However, if the characters were<br>
already typed they are used.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:map-<silent>" name=":map-&lt;silent&gt;">:map-&lt;silent&gt;</a>&nbsp;<a class="Constant" href="map.html#:map-silent" name=":map-silent">:map-silent</a><br>
To define a mapping which will not be echoed on the command line, add<br>
&quot;<span class="Special">&lt;silent&gt;</span>&quot; as the first argument.&nbsp;&nbsp;Example:<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:map &lt;silent&gt; ,h /Header&lt;CR&gt;</div>
The search string will not be echoed when using this mapping.&nbsp;&nbsp;Messages from<br>
the executed command are still given though.&nbsp;&nbsp;To shut them up too, add a<br>
&quot;:silent&quot; in the executed command:<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:map &lt;silent&gt; ,h :exe &quot;:silent normal /Header\r&quot;&lt;CR&gt;</div>
Prompts will still be given, e.g., for inputdialog().<br>
Using &quot;<span class="Special">&lt;silent&gt;</span>&quot; for an abbreviation is possible, but will cause redrawing of<br>
the command line to fail.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:map-<special>" name=":map-&lt;special&gt;">:map-&lt;special&gt;</a>&nbsp;<a class="Constant" href="map.html#:map-special" name=":map-special">:map-special</a><br>
Define a mapping with &lt;&gt; notation for special keys, even though the &quot;&lt;&quot; flag<br>
may appear in&nbsp;<a class="Type" href="options.html#'cpoptions'">'cpoptions'</a>.&nbsp;&nbsp;This is useful if the side effect of setting<br>
<a class="Type" href="options.html#'cpoptions'">'cpoptions'</a>&nbsp;is not desired.&nbsp;&nbsp;Example:<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:map &lt;special&gt; &lt;F12&gt; /Header&lt;CR&gt;</div>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:map-<script>" name=":map-&lt;script&gt;">:map-&lt;script&gt;</a>&nbsp;<a class="Constant" href="map.html#:map-script" name=":map-script">:map-script</a><br>
If the first argument to one of these commands is &quot;<span class="Special">&lt;script&gt;</span>&quot; and it is used to<br>
define a new mapping or abbreviation, the mapping will only remap characters<br>
in the&nbsp;<span class="Special">{rhs}</span>&nbsp;using mappings that were defined local to a script, starting with<br>
&quot;<span class="Special">&lt;SID&gt;</span>&quot;.&nbsp;&nbsp;This can be used to avoid that mappings from outside a script<br>
interfere (e.g., when&nbsp;<span class="Special">CTRL-V</span>&nbsp;is remapped in mswin.vim), but do use other<br>
mappings defined in the script.<br>
<span class="Todo">Note</span>: &quot;:map&nbsp;<span class="Special">&lt;script&gt;</span>&quot; and &quot;:noremap&nbsp;<span class="Special">&lt;script&gt;</span>&quot; do the same thing.&nbsp;&nbsp;The<br>
&quot;<span class="Special">&lt;script&gt;</span>&quot; overrules the command name.&nbsp;&nbsp;Using &quot;:noremap&nbsp;<span class="Special">&lt;script&gt;</span>&quot; is<br>
preferred, because it's clearer that remapping is (mostly) disabled.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:map-<unique>" name=":map-&lt;unique&gt;">:map-&lt;unique&gt;</a>&nbsp;<a class="Constant" href="map.html#E226" name="E226">E226</a>&nbsp;<a class="Constant" href="map.html#E227" name="E227">E227</a><br>
If the first argument to one of these commands is &quot;<span class="Special">&lt;unique&gt;</span>&quot; and it is used to<br>
define a new mapping or abbreviation, the command will fail if the mapping or<br>
abbreviation already exists.&nbsp;&nbsp;Example:<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:map &lt;unique&gt; ,w&nbsp;&nbsp;/[#&amp;!]&lt;CR&gt;</div>
When defining a local mapping, there will also be a check if a global map<br>
already exists which is equal.<br>
Example of what will fail:<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:map ,w&nbsp;&nbsp;/[#&amp;!]&lt;CR&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:map &lt;buffer&gt; &lt;unique&gt; ,w&nbsp;&nbsp;/[.,;]&lt;CR&gt;</div>
If you want to map a key and then have it do what it was originally mapped to,<br>
have a look at&nbsp;<a class="Identifier" href="eval.html#maparg()">maparg()</a>.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:map-<expr>" name=":map-&lt;expr&gt;">:map-&lt;expr&gt;</a>&nbsp;<a class="Constant" href="map.html#:map-expression" name=":map-expression">:map-expression</a><br>
If the first argument to one of these commands is &quot;<span class="Special">&lt;expr&gt;</span>&quot; and it is used to<br>
define a new mapping or abbreviation, the argument is an expression.&nbsp;&nbsp;The<br>
expression is evaluated to obtain the&nbsp;<span class="Special">{rhs}</span>&nbsp;that is used.&nbsp;&nbsp;Example:<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:inoremap &lt;expr&gt; . InsertDot()</div>
The result of the InsertDot() function will be inserted.&nbsp;&nbsp;It could check the<br>
text before the cursor and start omni completion when some condition is met.<br>
<br>
For abbreviations&nbsp;<a class="Identifier" href="eval.html#v:char">v:char</a>&nbsp;is set to the character that was typed to trigger<br>
the abbreviation.&nbsp;&nbsp;You can use this to decide how to expand the&nbsp;<span class="Special">{lhs}</span>.&nbsp;&nbsp;You<br>
should not either insert or change the v:char.<br>
<br>
Be very careful about side effects!&nbsp;&nbsp;The expression is evaluated while<br>
obtaining characters, you may very well make the command dysfunctional.<br>
For this reason the following is blocked:<br>
- Changing the buffer text&nbsp;<a class="Identifier" href="eval.html#textlock">textlock</a>.<br>
- Editing another buffer.<br>
- The&nbsp;<a class="Identifier" href="various.html#:normal">:normal</a>&nbsp;command.<br>
- Moving the cursor is allowed, but it is restored afterwards.<br>
If you want the mapping to do any of these let the returned characters do<br>
that.<br>
<br>
You can use getchar(), it consumes typeahead if there is any. E.g., if you<br>
have these mappings:<br>
<div class="helpExample">&nbsp;&nbsp;inoremap &lt;expr&gt; &lt;C-L&gt; nr2char(getchar())<br>
&nbsp;&nbsp;inoremap &lt;expr&gt; &lt;C-L&gt;x &quot;foo&quot;</div>
If you now type&nbsp;<span class="Special">CTRL-L</span>&nbsp;nothing happens yet, Vim needs the next character to<br>
decide what mapping to use.&nbsp;&nbsp;If you type 'x' the second mapping is used and<br>
&quot;foo&quot; is inserted.&nbsp;&nbsp;If you type any other key the first mapping is used,<br>
getchar() gets the typed key and returns it.<br>
<br>
Here is an example that inserts a list number that increases:<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;let counter = 0<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;inoremap &lt;expr&gt; &lt;C-L&gt; ListItem()<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;inoremap &lt;expr&gt; &lt;C-R&gt; ListReset()</div>
<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;func ListItem()<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;let g:counter += 1<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return g:counter . '. '<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;endfunc</div>
<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;func ListReset()<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;let g:counter = 0<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return ''<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;endfunc</div>
<br>
<span class="Special">CTRL-L</span>&nbsp;inserts the next number,&nbsp;<span class="Special">CTRL-R</span>&nbsp;resets the count.&nbsp;&nbsp;<span class="Special">CTRL-R</span>&nbsp;returns an<br>
empty string, so that nothing is inserted.<br>
<br>
<span class="Todo">Note</span>&nbsp;that there are some tricks to make special keys work and escape CSI bytes<br>
in the text.&nbsp;&nbsp;The&nbsp;<a class="Identifier" href="map.html#:map">:map</a>&nbsp;command also does this, thus you must avoid that it<br>
is done twice.&nbsp;&nbsp;This does not work:<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:imap &lt;expr&gt; &lt;F3&gt; &quot;&lt;Char-0x611B&gt;&quot;</div>
Because the &lt;Char- sequence is escaped for being a&nbsp;<a class="Identifier" href="map.html#:imap">:imap</a>&nbsp;argument and then<br>
again for using&nbsp;<span class="Special">&lt;expr&gt;</span>.&nbsp;&nbsp;This does work:<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:imap &lt;expr&gt; &lt;F3&gt; &quot;\u611B&quot;</div>
Using 0x80 as a single byte before other text does not work, it will be seen<br>
as a special key.<br>
<br>
<br>
1.3 MAPPING AND MODES&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:map-modes" name=":map-modes">:map-modes</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#mapmode-nvo" name="mapmode-nvo">mapmode-nvo</a>&nbsp;<a class="Constant" href="map.html#mapmode-n" name="mapmode-n">mapmode-n</a>&nbsp;<a class="Constant" href="map.html#mapmode-v" name="mapmode-v">mapmode-v</a>&nbsp;<a class="Constant" href="map.html#mapmode-o" name="mapmode-o">mapmode-o</a><br>
<br>
There are six sets of mappings<br>
- For Normal mode: When typing commands.<br>
- For Visual mode: When typing commands while the Visual area is highlighted.<br>
- For Select mode: like Visual mode but typing text replaces the selection.<br>
- For Operator-pending mode: When an operator is pending (after &quot;d&quot;, &quot;y&quot;, &quot;c&quot;,<br>
&nbsp;&nbsp;etc.).&nbsp;&nbsp;See below:&nbsp;<a class="Identifier" href="map.html#omap-info">omap-info</a>.<br>
- For Insert mode.&nbsp;&nbsp;These are also used in Replace mode.<br>
- For Command-line mode: When entering a &quot;:&quot; or &quot;/&quot; command.<br>
<br>
Special case: While typing a count for a command in Normal mode, mapping zero<br>
is disabled.&nbsp;&nbsp;This makes it possible to map zero without making it impossible<br>
to type a count with a zero.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#map-overview" name="map-overview">map-overview</a>&nbsp;<a class="Constant" href="map.html#map-modes" name="map-modes">map-modes</a><br>
Overview of which map command works in which mode.&nbsp;&nbsp;More details below.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="PreProc">COMMANDS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MODES</span><br>
:map&nbsp;&nbsp; :noremap&nbsp;&nbsp;:unmap&nbsp;&nbsp;&nbsp;&nbsp; Normal, Visual, Select, Operator-pending<br>
:nmap&nbsp;&nbsp;:nnoremap :nunmap&nbsp;&nbsp;&nbsp;&nbsp;Normal<br>
:vmap&nbsp;&nbsp;:vnoremap :vunmap&nbsp;&nbsp;&nbsp;&nbsp;Visual and Select<br>
:smap&nbsp;&nbsp;:snoremap :sunmap&nbsp;&nbsp;&nbsp;&nbsp;Select<br>
:xmap&nbsp;&nbsp;:xnoremap :xunmap&nbsp;&nbsp;&nbsp;&nbsp;Visual<br>
:omap&nbsp;&nbsp;:onoremap :ounmap&nbsp;&nbsp;&nbsp;&nbsp;Operator-pending<br>
:map!&nbsp;&nbsp;:noremap! :unmap!&nbsp;&nbsp;&nbsp;&nbsp;Insert and Command-line<br>
:imap&nbsp;&nbsp;:inoremap :iunmap&nbsp;&nbsp;&nbsp;&nbsp;Insert<br>
:lmap&nbsp;&nbsp;:lnoremap :lunmap&nbsp;&nbsp;&nbsp;&nbsp;Insert, Command-line, Lang-Arg<br>
:cmap&nbsp;&nbsp;:cnoremap :cunmap&nbsp;&nbsp;&nbsp;&nbsp;Command-line<br>
<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;<span class="PreProc">COMMANDS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MODES</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="PreProc">Normal&nbsp;&nbsp;Visual+Select&nbsp;&nbsp;Operator-pending</span><br>
:map&nbsp;&nbsp; :noremap&nbsp;&nbsp; :unmap&nbsp;&nbsp; :mapclear&nbsp;&nbsp;&nbsp;&nbsp; yes&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;yes&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;yes<br>
:nmap&nbsp;&nbsp;:nnoremap&nbsp;&nbsp;:nunmap&nbsp;&nbsp;:nmapclear&nbsp;&nbsp;&nbsp;&nbsp;yes&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-<br>
:vmap&nbsp;&nbsp;:vnoremap&nbsp;&nbsp;:vunmap&nbsp;&nbsp;:vmapclear&nbsp;&nbsp;&nbsp;&nbsp; -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; yes&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -<br>
:omap&nbsp;&nbsp;:onoremap&nbsp;&nbsp;:ounmap&nbsp;&nbsp;:omapclear&nbsp;&nbsp;&nbsp;&nbsp; -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; yes<br>
<br>
:nunmap can also be used outside of a monastery.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#mapmode-x" name="mapmode-x">mapmode-x</a>&nbsp;<a class="Constant" href="map.html#mapmode-s" name="mapmode-s">mapmode-s</a><br>
Some commands work both in Visual and Select mode, some in only one.&nbsp;&nbsp;<span class="Todo">Note</span><br>
that quite often &quot;Visual&quot; is mentioned where both Visual and Select mode<br>
apply.&nbsp;<a class="Identifier" href="visual.html#Select-mode-mapping">Select-mode-mapping</a><br>
<span class="Todo">NOTE</span>: Mapping a printable character in Select mode may confuse the user.&nbsp;&nbsp;It's<br>
better to explicitly use :xmap and :smap for printable characters.&nbsp;&nbsp;Or use<br>
:sunmap after defining the mapping.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;<span class="PreProc">COMMANDS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MODES</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="PreProc">Visual&nbsp;&nbsp;&nbsp;&nbsp;Select</span><br>
:vmap&nbsp;&nbsp;:vnoremap&nbsp;&nbsp;:vunmap&nbsp;&nbsp;:vmapclear&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; yes&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;yes<br>
:xmap&nbsp;&nbsp;:xnoremap&nbsp;&nbsp;:xunmap&nbsp;&nbsp;:xmapclear&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; yes&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -<br>
:smap&nbsp;&nbsp;:snoremap&nbsp;&nbsp;:sunmap&nbsp;&nbsp;:smapclear&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;yes<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#mapmode-ic" name="mapmode-ic">mapmode-ic</a>&nbsp;<a class="Constant" href="map.html#mapmode-i" name="mapmode-i">mapmode-i</a>&nbsp;<a class="Constant" href="map.html#mapmode-c" name="mapmode-c">mapmode-c</a>&nbsp;<a class="Constant" href="map.html#mapmode-l" name="mapmode-l">mapmode-l</a><br>
Some commands work both in Insert mode and Command-line mode, some not:<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;<span class="PreProc">COMMANDS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MODES</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="PreProc">Insert&nbsp;&nbsp;Command-line&nbsp;&nbsp;Lang-Arg</span><br>
:map!&nbsp;&nbsp;:noremap!&nbsp;&nbsp;:unmap!&nbsp;&nbsp;:mapclear!&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; yes&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;yes&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -<br>
:imap&nbsp;&nbsp;:inoremap&nbsp;&nbsp;:iunmap&nbsp;&nbsp;:imapclear&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; yes&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-<br>
:cmap&nbsp;&nbsp;:cnoremap&nbsp;&nbsp;:cunmap&nbsp;&nbsp;:cmapclear&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; yes&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -<br>
:lmap&nbsp;&nbsp;:lnoremap&nbsp;&nbsp;:lunmap&nbsp;&nbsp;:lmapclear&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; yes*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; yes*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; yes*<br>
<br>
The original Vi did not have separate mappings for<br>
Normal/Visual/Operator-pending mode and for Insert/Command-line mode.<br>
Therefore the &quot;:map&quot; and &quot;:map!&quot; commands enter and display mappings for<br>
several modes.&nbsp;&nbsp;In Vim you can use the &quot;:nmap&quot;, &quot;:vmap&quot;, &quot;:omap&quot;, &quot;:cmap&quot; and<br>
&quot;:imap&quot; commands to enter mappings for each mode separately.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#omap-info" name="omap-info">omap-info</a><br>
Operator-pending mappings can be used to define a movement command that can be<br>
used with any operator.&nbsp;&nbsp;Simple example: &quot;:omap { w&quot; makes &quot;y{&quot; work like &quot;yw&quot;<br>
and &quot;d{&quot; like &quot;dw&quot;.<br>
<br>
To ignore the starting cursor position and select different text, you can have<br>
the omap start Visual mode to select the text to be operated upon.&nbsp;&nbsp;Example<br>
that operates on a function name in the current line:<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;onoremap &lt;silent&gt; F :&lt;C-U&gt;normal! 0f(hviw&lt;CR&gt;</div>
The&nbsp;<span class="Special">CTRL-U</span>&nbsp;(<span class="Special">&lt;C-U&gt;</span>) is used to remove the range that Vim may insert.&nbsp;&nbsp;The<br>
Normal mode commands find the first '(' character and select the first word<br>
before it.&nbsp;&nbsp;That usually is the function name.<br>
<br>
To enter a mapping for Normal and Visual mode, but not Operator-pending mode,<br>
first define it for all three modes, then unmap it for Operator-pending mode:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:map&nbsp;&nbsp;&nbsp;&nbsp;xx something-difficult<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:ounmap xx<br>
Likewise for a mapping for Visual and Operator-pending mode or Normal and<br>
Operator-pending mode.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#language-mapping" name="language-mapping">language-mapping</a><br>
&quot;:lmap&quot; defines a mapping that applies to:<br>
- Insert mode<br>
- Command-line mode<br>
- when entering a search pattern<br>
- the argument of the commands that accept a text character, such as &quot;r&quot; and<br>
&nbsp;&nbsp;&quot;f&quot;<br>
- for the input() line<br>
Generally: Whenever a character is to be typed that is part of the text in the<br>
buffer, not a Vim command character.&nbsp;&nbsp;&quot;Lang-Arg&quot; isn't really another mode,<br>
it's just used here for this situation.<br>
&nbsp;&nbsp; The simplest way to load a set of related language mappings is by using the<br>
<a class="Type" href="options.html#'keymap'">'keymap'</a>&nbsp;option.&nbsp;&nbsp;See&nbsp;<a class="Identifier" href="usr_45.html#45.5">45.5</a>.<br>
&nbsp;&nbsp; In Insert mode and in Command-line mode the mappings can be disabled with<br>
the&nbsp;<span class="Special">CTRL-^</span>&nbsp;command&nbsp;<a class="Identifier" href="insert.html#i_CTRL-^">i_CTRL-^</a>&nbsp;<a class="Identifier" href="cmdline.html#c_CTRL-^">c_CTRL-^</a>. These commands change the value of<br>
the&nbsp;<a class="Type" href="options.html#'iminsert'">'iminsert'</a>&nbsp;option.&nbsp;&nbsp;When starting to enter a normal command line (not a<br>
search pattern) the mappings are disabled until a&nbsp;<span class="Special">CTRL-^</span>&nbsp;is typed.&nbsp;&nbsp;The state<br>
last used is remembered for Insert mode and Search patterns separately.&nbsp;&nbsp;The<br>
state for Insert mode is also used when typing a character as an argument to<br>
command like &quot;f&quot; or &quot;t&quot;.<br>
&nbsp;&nbsp; Language mappings will never be applied to already mapped characters.&nbsp;&nbsp;They<br>
are only used for typed characters.&nbsp;&nbsp;This assumes that the language mapping<br>
was already done when typing the mapping.<br>
<br>
<br>
1.4 LISTING MAPPINGS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#map-listing" name="map-listing">map-listing</a><br>
<br>
When listing mappings the characters in the first two columns are:<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="PreProc">CHAR&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MODE</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="Special">&lt;Space&gt;</span>&nbsp;&nbsp;&nbsp;&nbsp;Normal, Visual, Select and Operator-pending<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Normal<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;v&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Visual and Select<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;s&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Select<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;x&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Visual<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;o&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Operator-pending<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;!&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Insert and Command-line<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;i&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Insert<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;l&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;:lmap&quot; mappings for Insert, Command-line and Lang-Arg<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;c&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Command-line<br>
<br>
Just before the&nbsp;<span class="Special">{rhs}</span>&nbsp;a special character can appear:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; indicates that it is not remappable<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&amp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; indicates that only script-local mappings are remappable<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; indicates a buffer-local mapping<br>
<br>
Everything from the first non-blank after&nbsp;<span class="Special">{lhs}</span>&nbsp;up to the end of the line<br>
(or '|') is considered to be part of&nbsp;<span class="Special">{rhs}</span>.&nbsp;&nbsp;This allows the&nbsp;<span class="Special">{rhs}</span>&nbsp;to end<br>
with a space.<br>
<br>
<span class="Todo">Note</span>: When using mappings for Visual mode, you can use the &quot;'&lt;&quot; mark, which<br>
is the start of the last selected Visual area in the current buffer&nbsp;<a class="Identifier" href="motion.html#'<">'&lt;</a>.<br>
<br>
The&nbsp;<a class="Identifier" href="various.html#:filter">:filter</a>&nbsp;command can be used to select what mappings to list.&nbsp;&nbsp;The<br>
pattern is matched against the&nbsp;<span class="Special">{lhs}</span>&nbsp;and&nbsp;<span class="Special">{rhs}</span>&nbsp;in the raw form.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:map-verbose" name=":map-verbose">:map-verbose</a><br>
When&nbsp;<a class="Type" href="options.html#'verbose'">'verbose'</a>&nbsp;is non-zero, listing a key map will also display where it was<br>
last defined.&nbsp;&nbsp;Example:<br>
<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:verbose map &lt;C-W&gt;*<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;n&nbsp;&nbsp;&lt;C-W&gt;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* &lt;C-W&gt;&lt;C-S&gt;*<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Last set from /home/abcd/.vimrc</div>
<br>
See&nbsp;<a class="Identifier" href="various.html#:verbose-cmd">:verbose-cmd</a>&nbsp;for more information.<br>
<br>
<br>
1.5 MAPPING SPECIAL KEYS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:map-special-keys" name=":map-special-keys">:map-special-keys</a><br>
<br>
There are three ways to map a special key:<br>
1. The Vi-compatible method: Map the key code.&nbsp;&nbsp;Often this is a sequence that<br>
&nbsp;&nbsp; starts with&nbsp;<span class="Special">&lt;Esc&gt;</span>.&nbsp;&nbsp;To enter a mapping like this you type &quot;:map &quot; and then<br>
&nbsp;&nbsp; you have to type&nbsp;<span class="Special">CTRL-V</span>&nbsp;before hitting the function key.&nbsp;&nbsp;<span class="Todo">Note</span>&nbsp;that when<br>
&nbsp;&nbsp; the key code for the key is in the termcap (the t_ options), it will<br>
&nbsp;&nbsp; automatically be translated into the internal code and become the second<br>
&nbsp;&nbsp; way of mapping (unless the 'k' flag is included in&nbsp;<a class="Type" href="options.html#'cpoptions'">'cpoptions'</a>).<br>
2. The second method is to use the internal code for the function key.&nbsp;&nbsp;To<br>
&nbsp;&nbsp; enter such a mapping type&nbsp;<span class="Special">CTRL-K</span>&nbsp;and then hit the function key, or use<br>
&nbsp;&nbsp; the form &quot;#1&quot;, &quot;#2&quot;, .. &quot;#9&quot;, &quot;#0&quot;, &quot;<span class="Special">&lt;Up&gt;</span>&quot;, &quot;<span class="Special">&lt;S-Down&gt;</span>&quot;, &quot;<span class="Special">&lt;S-F7&gt;</span>&quot;, etc.<br>
&nbsp;&nbsp; (see table of keys&nbsp;<a class="Identifier" href="intro.html#key-notation">key-notation</a>, all keys from&nbsp;<span class="Special">&lt;Up&gt;</span>&nbsp;can be used).&nbsp;&nbsp;The<br>
&nbsp;&nbsp; first ten function keys can be defined in two ways: Just the number, like<br>
&nbsp;&nbsp; &quot;#2&quot;, and with &quot;<span class="Special">&lt;F&gt;</span>&quot;, like &quot;<span class="Special">&lt;F2&gt;</span>&quot;.&nbsp;&nbsp;Both stand for function key 2.&nbsp;&nbsp;&quot;#0&quot;<br>
&nbsp;&nbsp; refers to function key 10, defined with option 't_f10', which may be<br>
&nbsp;&nbsp; function key zero on some keyboards.&nbsp;&nbsp;The &lt;&gt; form cannot be used when<br>
&nbsp;&nbsp;&nbsp;<a class="Type" href="options.html#'cpoptions'">'cpoptions'</a>&nbsp;includes the '&lt;' flag.<br>
3. Use the termcap entry, with the form&nbsp;<span class="Special">&lt;t_xx&gt;</span>, where &quot;xx&quot; is the name of the<br>
&nbsp;&nbsp; termcap entry.&nbsp;&nbsp;Any string entry can be used.&nbsp;&nbsp;For example:<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp; :map &lt;t_F3&gt; G</div>
&nbsp;&nbsp;&nbsp;Maps function key 13 to &quot;G&quot;.&nbsp;&nbsp;This does not work if&nbsp;<a class="Type" href="options.html#'cpoptions'">'cpoptions'</a>&nbsp;includes<br>
&nbsp;&nbsp; the '&lt;' flag.<br>
<br>
The advantage of the second and third method is that the mapping will work on<br>
different terminals without modification (the function key will be<br>
translated into the same internal code or the actual key code, no matter what<br>
terminal you are using.&nbsp;&nbsp;The termcap must be correct for this to work, and you<br>
must use the same mappings).<br>
<br>
DETAIL: Vim first checks if a sequence from the keyboard is mapped.&nbsp;&nbsp;If it<br>
isn't the terminal key codes are tried (see&nbsp;<a class="Identifier" href="term.html#terminal-options">terminal-options</a>).&nbsp;&nbsp;If a<br>
terminal code is found it is replaced with the internal code.&nbsp;&nbsp;Then the check<br>
for a mapping is done again (so you can map an internal code to something<br>
else).&nbsp;&nbsp;What is written into the script file depends on what is recognized.<br>
If the terminal key code was recognized as a mapping the key code itself is<br>
written to the script file.&nbsp;&nbsp;If it was recognized as a terminal code the<br>
internal code is written to the script file.<br>
<br>
<br>
1.6 SPECIAL CHARACTERS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:map-special-chars" name=":map-special-chars">:map-special-chars</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#map_backslash" name="map_backslash">map_backslash</a>&nbsp;<a class="Constant" href="map.html#map-backslash" name="map-backslash">map-backslash</a><br>
<span class="Todo">Note</span>&nbsp;that only&nbsp;<span class="Special">CTRL-V</span>&nbsp;is mentioned here as a special character for mappings<br>
and abbreviations.&nbsp;&nbsp;When&nbsp;<a class="Type" href="options.html#'cpoptions'">'cpoptions'</a>&nbsp;does not contain 'B', a backslash can<br>
also be used like&nbsp;<span class="Special">CTRL-V</span>.&nbsp;&nbsp;The &lt;&gt; notation can be fully used then&nbsp;<a class="Identifier" href="intro.html#<>">&lt;&gt;</a>.&nbsp;&nbsp;But<br>
you cannot use &quot;<span class="Special">&lt;C-V&gt;</span>&quot; like&nbsp;<span class="Special">CTRL-V</span>&nbsp;to escape the special meaning of what<br>
follows.<br>
<br>
To map a backslash, or use a backslash literally in the&nbsp;<span class="Special">{rhs}</span>, the special<br>
sequence &quot;<span class="Special">&lt;Bslash&gt;</span>&quot; can be used.&nbsp;&nbsp;This avoids the need to double backslashes<br>
when using nested mappings.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#map_CTRL-C" name="map_CTRL-C">map_CTRL-C</a>&nbsp;<a class="Constant" href="map.html#map-CTRL-C" name="map-CTRL-C">map-CTRL-C</a><br>
Using&nbsp;<span class="Special">CTRL-C</span>&nbsp;in the&nbsp;<span class="Special">{lhs}</span>&nbsp;is possible, but it will only work when Vim is<br>
waiting for a key, not when Vim is busy with something.&nbsp;&nbsp;When Vim is busy<br>
<span class="Special">CTRL-C</span>&nbsp;interrupts/breaks the command.<br>
When using the GUI version on MS-Windows&nbsp;<span class="Special">CTRL-C</span>&nbsp;can be mapped to allow a Copy<br>
command to the clipboard.&nbsp;&nbsp;Use&nbsp;<span class="Special">CTRL-Break</span>&nbsp;to interrupt Vim.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#map_space_in_lhs" name="map_space_in_lhs">map_space_in_lhs</a>&nbsp;<a class="Constant" href="map.html#map-space_in_lhs" name="map-space_in_lhs">map-space_in_lhs</a><br>
To include a space in&nbsp;<span class="Special">{lhs}</span>&nbsp;precede it with a&nbsp;<span class="Special">CTRL-V</span>&nbsp;(type two&nbsp;<span class="Special">CTRL-V</span>s for<br>
each space).<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#map_space_in_rhs" name="map_space_in_rhs">map_space_in_rhs</a>&nbsp;<a class="Constant" href="map.html#map-space_in_rhs" name="map-space_in_rhs">map-space_in_rhs</a><br>
If you want a&nbsp;<span class="Special">{rhs}</span>&nbsp;that starts with a space, use &quot;<span class="Special">&lt;Space&gt;</span>&quot;.&nbsp;&nbsp;To be fully Vi<br>
compatible (but unreadable) don't use the&nbsp;<a class="Identifier" href="intro.html#<>">&lt;&gt;</a>&nbsp;notation, precede&nbsp;<span class="Special">{rhs}</span>&nbsp;with a<br>
single&nbsp;<span class="Special">CTRL-V</span>&nbsp;(you have to type&nbsp;<span class="Special">CTRL-V</span>&nbsp;two times).<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#map_empty_rhs" name="map_empty_rhs">map_empty_rhs</a>&nbsp;<a class="Constant" href="map.html#map-empty-rhs" name="map-empty-rhs">map-empty-rhs</a><br>
You can create an empty&nbsp;<span class="Special">{rhs}</span>&nbsp;by typing nothing after a single&nbsp;<span class="Special">CTRL-V</span>&nbsp;(you<br>
have to type&nbsp;<span class="Special">CTRL-V</span>&nbsp;two times).&nbsp;&nbsp;Unfortunately, you cannot do this in a vimrc<br>
file.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#<Nop>" name="&lt;Nop&gt;">&lt;Nop&gt;</a><br>
An easier way to get a mapping that doesn't produce anything, is to use<br>
&quot;<span class="Special">&lt;Nop&gt;</span>&quot; for the&nbsp;<span class="Special">{rhs}</span>.&nbsp;&nbsp;This only works when the&nbsp;<a class="Identifier" href="intro.html#<>">&lt;&gt;</a>&nbsp;notation is enabled.<br>
For example, to make sure that function key 8 does nothing at all:<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:map&nbsp;&nbsp;&lt;F8&gt;&nbsp;&nbsp;&lt;Nop&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:map! &lt;F8&gt;&nbsp;&nbsp;&lt;Nop&gt;</div>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#map-multibyte" name="map-multibyte">map-multibyte</a><br>
It is possible to map multibyte characters, but only the whole character.&nbsp;&nbsp;You<br>
cannot map the first byte only.&nbsp;&nbsp;This was done to prevent problems in this<br>
scenario:<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:set encoding=latin1<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:imap &lt;M-C&gt; foo<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:set encoding=utf-8</div>
The mapping for&nbsp;<span class="Special">&lt;M-C&gt;</span>&nbsp;is defined with the latin1 encoding, resulting in a 0xc3<br>
byte.&nbsp;&nbsp;If you type the character ? (0xe1&nbsp;<span class="Special">&lt;M-a&gt;</span>) in UTF-8 encoding this is the<br>
two bytes 0xc3 0xa1.&nbsp;&nbsp;You don't want the 0xc3 byte to be mapped then or<br>
otherwise it would be impossible to type the ? character.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#<Leader>" name="&lt;Leader&gt;">&lt;Leader&gt;</a>&nbsp;<a class="Constant" href="map.html#mapleader" name="mapleader">mapleader</a><br>
To define a mapping which uses the &quot;mapleader&quot; variable, the special string<br>
&quot;<span class="Special">&lt;Leader&gt;</span>&quot; can be used.&nbsp;&nbsp;It is replaced with the string value of &quot;mapleader&quot;.<br>
If &quot;mapleader&quot; is not set or empty, a backslash is used instead.&nbsp;&nbsp;Example:<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:map &lt;Leader&gt;A&nbsp;&nbsp;oanother line&lt;Esc&gt;</div>
Works like:<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:map \A&nbsp;&nbsp;oanother line&lt;Esc&gt;</div>
But after:<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:let mapleader = &quot;,&quot;</div>
It works like:<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:map ,A&nbsp;&nbsp;oanother line&lt;Esc&gt;</div>
<br>
<span class="Todo">Note</span>&nbsp;that the value of &quot;mapleader&quot; is used at the moment the mapping is<br>
defined.&nbsp;&nbsp;Changing &quot;mapleader&quot; after that has no effect for already defined<br>
mappings.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#<LocalLeader>" name="&lt;LocalLeader&gt;">&lt;LocalLeader&gt;</a>&nbsp;<a class="Constant" href="map.html#maplocalleader" name="maplocalleader">maplocalleader</a><br>
<span class="Special">&lt;LocalLeader&gt;</span>&nbsp;is just like&nbsp;<span class="Special">&lt;Leader&gt;</span>, except that it uses &quot;maplocalleader&quot;<br>
instead of &quot;mapleader&quot;.&nbsp;&nbsp;<span class="Special">&lt;LocalLeader&gt;</span>&nbsp;is to be used for mappings which are<br>
local to a buffer.&nbsp;&nbsp;Example:<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:map &lt;buffer&gt; &lt;LocalLeader&gt;A&nbsp;&nbsp;oanother line&lt;Esc&gt;</div>
<br>
In a global plugin&nbsp;<span class="Special">&lt;Leader&gt;</span>&nbsp;should be used and in a filetype plugin<br>
<span class="Special">&lt;LocalLeader&gt;</span>.&nbsp;&nbsp;&quot;mapleader&quot; and &quot;maplocalleader&quot; can be equal.&nbsp;&nbsp;Although, if<br>
you make them different, there is a smaller chance of mappings from global<br>
plugins to clash with mappings for filetype plugins.&nbsp;&nbsp;For example, you could<br>
keep &quot;mapleader&quot; at the default backslash, and set &quot;maplocalleader&quot; to an<br>
underscore.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#map-<SID>" name="map-&lt;SID&gt;">map-&lt;SID&gt;</a><br>
In a script the special key name &quot;<span class="Special">&lt;SID&gt;</span>&quot; can be used to define a mapping<br>
that's local to the script.&nbsp;&nbsp;See&nbsp;<a class="Identifier" href="map.html#<SID>">&lt;SID&gt;</a>&nbsp;for details.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#<Plug>" name="&lt;Plug&gt;">&lt;Plug&gt;</a><br>
The special key name &quot;<span class="Special">&lt;Plug&gt;</span>&quot; can be used for an internal mapping, which is<br>
not to be matched with any key sequence.&nbsp;&nbsp;This is useful in plugins<br>
<a class="Identifier" href="usr_41.html#using-<Plug>">using-&lt;Plug&gt;</a>.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#<Char>" name="&lt;Char&gt;">&lt;Char&gt;</a>&nbsp;<a class="Constant" href="map.html#<Char->" name="&lt;Char-&gt;">&lt;Char-&gt;</a><br>
To map a character by its decimal, octal or hexadecimal number the&nbsp;<span class="Special">&lt;Char&gt;</span><br>
construct can be used:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="Special">&lt;Char-123&gt;</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;character 123<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="Special">&lt;Char-033&gt;</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;character 27<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="Special">&lt;Char-0x7f&gt;</span>&nbsp;&nbsp;&nbsp;&nbsp; character 127<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="Special">&lt;S-Char-114&gt;</span>&nbsp;&nbsp;&nbsp;&nbsp;character 114 ('r') shifted ('R')<br>
This is useful to specify a (multi-byte) character in a&nbsp;<a class="Type" href="options.html#'keymap'">'keymap'</a>&nbsp;file.<br>
Upper and lowercase differences are ignored.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#map-comments" name="map-comments">map-comments</a><br>
It is not possible to put a comment after these commands, because the '&quot;'<br>
character is considered to be part of the&nbsp;<span class="Special">{lhs}</span>&nbsp;or&nbsp;<span class="Special">{rhs}</span>. However, one can<br>
use |&quot;, since this starts a new, empty command with a comment.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#map_bar" name="map_bar">map_bar</a>&nbsp;<a class="Constant" href="map.html#map-bar" name="map-bar">map-bar</a><br>
Since the '|' character is used to separate a map command from the next<br>
command, you will have to do something special to include&nbsp;&nbsp;a '|' in&nbsp;<span class="Special">{rhs}</span>.<br>
There are three methods:<br>
&nbsp;&nbsp;&nbsp;<span class="PreProc">use&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; works when&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;example</span><br>
&nbsp;&nbsp;&nbsp;<span class="Special">&lt;Bar&gt;</span>&nbsp;&nbsp;&nbsp;&nbsp; '&lt;' is not in&nbsp;<a class="Type" href="options.html#'cpoptions'">'cpoptions'</a>&nbsp;&nbsp;&nbsp;&nbsp; :map _l :!ls&nbsp;<span class="Special">&lt;Bar&gt;</span>&nbsp;more^M<br>
&nbsp;&nbsp; \|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'b' is not in&nbsp;<a class="Type" href="options.html#'cpoptions'">'cpoptions'</a>&nbsp;&nbsp;&nbsp;&nbsp; :map _l :!ls \| more^M<br>
&nbsp;&nbsp; ^V|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; always, in Vim and Vi&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :map _l :!ls ^V| more^M<br>
<br>
(here ^V stands for&nbsp;<span class="Special">CTRL-V</span>; to get one&nbsp;<span class="Special">CTRL-V</span>&nbsp;you have to type it twice; you<br>
cannot use the &lt;&gt; notation &quot;<span class="Special">&lt;C-V&gt;</span>&quot; here).<br>
<br>
All three work when you use the default setting for&nbsp;<a class="Type" href="options.html#'cpoptions'">'cpoptions'</a>.<br>
<br>
When 'b' is present in&nbsp;<a class="Type" href="options.html#'cpoptions'">'cpoptions'</a>, &quot;\|&quot; will be recognized as a mapping<br>
ending in a '\' and then another command.&nbsp;&nbsp;This is Vi compatible, but<br>
illogical when compared to other commands.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#map_return" name="map_return">map_return</a>&nbsp;<a class="Constant" href="map.html#map-return" name="map-return">map-return</a><br>
When you have a mapping that contains an Ex command, you need to put a line<br>
terminator after it to have it executed.&nbsp;&nbsp;The use of&nbsp;<span class="Special">&lt;CR&gt;</span>&nbsp;is recommended for<br>
this (see&nbsp;<a class="Identifier" href="intro.html#<>">&lt;&gt;</a>).&nbsp;&nbsp;Example:<br>
<div class="helpExample">&nbsp;&nbsp; :map&nbsp;&nbsp;_ls&nbsp;&nbsp;:!ls -l %:S&lt;CR&gt;:echo &quot;the end&quot;&lt;CR&gt;</div>
<br>
To avoid mapping of the characters you type in insert or Command-line mode,<br>
type a&nbsp;<span class="Special">CTRL-V</span>&nbsp;first.&nbsp;&nbsp;The mapping in Insert mode is disabled if the&nbsp;<a class="Type" href="options.html#'paste'">'paste'</a><br>
option is on.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#map-error" name="map-error">map-error</a><br>
<span class="Todo">Note</span>&nbsp;that when an error is encountered (that causes an error message or beep)<br>
the rest of the mapping is not executed.&nbsp;&nbsp;This is Vi-compatible.<br>
<br>
<span class="Todo">Note</span>&nbsp;that the second character (argument) of the commands @zZtTfF[]rm'`&quot;v<br>
and&nbsp;<span class="Special">CTRL-X</span>&nbsp;is not mapped.&nbsp;&nbsp;This was done to be able to use all the named<br>
registers and marks, even when the command with the same name has been<br>
mapped.<br>
<br>
<br>
1.7 WHAT KEYS TO MAP&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#map-which-keys" name="map-which-keys">map-which-keys</a><br>
<br>
If you are going to map something, you will need to choose which key(s) to use<br>
for the&nbsp;<span class="Special">{lhs}</span>.&nbsp;&nbsp;You will have to avoid keys that are used for Vim commands,<br>
otherwise you would not be able to use those commands anymore.&nbsp;&nbsp;Here are a few<br>
suggestions:<br>
- Function keys&nbsp;<span class="Special">&lt;F2&gt;</span>,&nbsp;<span class="Special">&lt;F3&gt;</span>, etc..&nbsp;&nbsp;Also the shifted function keys&nbsp;<span class="Special">&lt;S-F1&gt;</span>,<br>
&nbsp;&nbsp;<span class="Special">&lt;S-F2&gt;</span>, etc.&nbsp;&nbsp;<span class="Todo">Note</span>&nbsp;that&nbsp;<span class="Special">&lt;F1&gt;</span>&nbsp;is already used for the help command.<br>
- Meta-keys (with the ALT key pressed).&nbsp;&nbsp;Depending on your keyboard accented<br>
&nbsp;&nbsp;characters may be used as well.&nbsp;<a class="Identifier" href="map.html#:map-alt-keys">:map-alt-keys</a><br>
- Use the '_' or ',' character and then any other character.&nbsp;&nbsp;The &quot;_&quot; and &quot;,&quot;<br>
&nbsp;&nbsp;commands do exist in Vim (see&nbsp;<a class="Identifier" href="motion.html#_">_</a>&nbsp;and&nbsp;<a class="Identifier" href="motion.html#,">,</a>), but you probably never use them.<br>
- Use a key that is a synonym for another command.&nbsp;&nbsp;For example:&nbsp;<span class="Special">CTRL-P</span>&nbsp;and<br>
&nbsp;&nbsp;<span class="Special">CTRL-N</span>.&nbsp;&nbsp;Use an extra character to allow more mappings.<br>
- The key defined by&nbsp;<span class="Special">&lt;Leader&gt;</span>&nbsp;and one or more other keys.&nbsp;&nbsp;This is especially<br>
&nbsp;&nbsp;useful in scripts.&nbsp;<a class="Identifier" href="map.html#mapleader">mapleader</a><br>
<br>
See the file &quot;index&quot; for keys that are not used and thus can be mapped without<br>
losing any builtin function.&nbsp;&nbsp;You can also use &quot;:help&nbsp;<span class="Special">{key}</span>^D&quot; to find out if<br>
a key is used for some command.&nbsp;&nbsp;(<span class="Special">{key}</span>&nbsp;is the specific key you want to find<br>
out about, ^D is&nbsp;<span class="Special">CTRL-D</span>).<br>
<br>
<br>
1.8 EXAMPLES&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#map-examples" name="map-examples">map-examples</a><br>
<br>
A few examples (given as you type them, for &quot;<span class="Special">&lt;CR&gt;</span>&quot; you type four characters;<br>
the '&lt;' flag must not be present in&nbsp;<a class="Type" href="options.html#'cpoptions'">'cpoptions'</a>&nbsp;for this to work).<br>
<br>
<div class="helpExample">&nbsp;&nbsp; :map &lt;F3&gt;&nbsp;&nbsp;o#include<br>
&nbsp;&nbsp; :map &lt;M-g&gt; /foo&lt;CR&gt;cwbar&lt;Esc&gt;<br>
&nbsp;&nbsp; :map _x&nbsp;&nbsp;&nbsp;&nbsp;d/END/e&lt;CR&gt;<br>
&nbsp;&nbsp; :map! qq&nbsp;&nbsp; quadrillion questions</div>
<br>
<br>
Multiplying a count<br>
<br>
When you type a count before triggering a mapping, it's like the count was<br>
typed before the&nbsp;<span class="Special">{lhs}</span>.&nbsp;&nbsp;For example, with this mapping:<br>
<div class="helpExample">&nbsp;&nbsp; :map &lt;F4&gt;&nbsp;&nbsp;3w</div>
Typing 2<span class="Special">&lt;F4&gt;</span>&nbsp;will result in &quot;23w&quot;. Thus not moving 2 * 3 words but 23 words.<br>
If you want to multiply counts use the expression register:<br>
<div class="helpExample">&nbsp;&nbsp; :map &lt;F4&gt;&nbsp;&nbsp;@='3w'&lt;CR&gt;</div>
The part between quotes is the expression being executed.&nbsp;<a class="Identifier" href="change.html#@=">@=</a><br>
<br>
<br>
1.9 USING MAPPINGS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#map-typing" name="map-typing">map-typing</a><br>
<br>
Vim will compare what you type with the start of a mapped sequence.&nbsp;&nbsp;If there<br>
is an incomplete match, it will get more characters until there either is a<br>
complete match or until there is no match at all.&nbsp;&nbsp;Example: If you map! &quot;qq&quot;,<br>
the first 'q' will not appear on the screen until you type another<br>
character.&nbsp;&nbsp;This is because Vim cannot know if the next character will be a<br>
'q' or not.&nbsp;&nbsp;If the&nbsp;<a class="Type" href="options.html#'timeout'">'timeout'</a>&nbsp;option is on (which is the default) Vim will<br>
only wait for one second (or as long as specified with the&nbsp;<a class="Type" href="options.html#'timeoutlen'">'timeoutlen'</a><br>
option).&nbsp;&nbsp;After that it assumes that the 'q' is to be interpreted as such.&nbsp;&nbsp;If<br>
you type slowly, or your system is slow, reset the&nbsp;<a class="Type" href="options.html#'timeout'">'timeout'</a>&nbsp;option.&nbsp;&nbsp;Then you<br>
might want to set the&nbsp;<a class="Type" href="options.html#'ttimeout'">'ttimeout'</a>&nbsp;option.<br>
<br>
<span class="Statement">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><a class="Constant" href="map.html#map-precedence" name="map-precedence">map-precedence</a><br>
Buffer-local mappings (defined using&nbsp;<a class="Identifier" href="map.html#:map-<buffer>">:map-&lt;buffer&gt;</a>) take precedence over<br>
global mappings.&nbsp;&nbsp;When a buffer-local mapping is the same as a global mapping,<br>
Vim will use the buffer-local mapping.&nbsp;&nbsp;In addition, Vim will use a complete<br>
mapping immediately if it was defined with&nbsp;<span class="Special">&lt;nowait&gt;</span>, even if a longer mapping<br>
has the same prefix.&nbsp;&nbsp;For example, given the following two mappings:<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp;:map &lt;buffer&gt; &lt;nowait&gt; \a&nbsp;&nbsp; :echo &quot;Local \a&quot;&lt;CR&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;:map&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \abc :echo &quot;Global \abc&quot;&lt;CR&gt;</div>
When typing \a the buffer-local mapping will be used immediately.&nbsp;&nbsp;Vim will<br>
not wait for more characters to see if the user might be typing \abc.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#map-keys-fails" name="map-keys-fails">map-keys-fails</a><br>
There are situations where key codes might not be recognized:<br>
- Vim can only read part of the key code.&nbsp;&nbsp;Mostly this is only the first<br>
&nbsp;&nbsp;character.&nbsp;&nbsp;This happens on some Unix versions in an xterm.<br>
- The key code is after character(s) that are mapped.&nbsp;&nbsp;E.g., &quot;<span class="Special">&lt;F1&gt;&lt;F1&gt;</span>&quot; or<br>
&nbsp;&nbsp;&quot;g<span class="Special">&lt;F1&gt;</span>&quot;.<br>
<br>
The result is that the key code is not recognized in this situation, and the<br>
mapping fails.&nbsp;&nbsp;There are two actions needed to avoid this problem:<br>
<br>
- Remove the 'K' flag from&nbsp;<a class="Type" href="options.html#'cpoptions'">'cpoptions'</a>.&nbsp;&nbsp;This will make Vim wait for the rest<br>
&nbsp;&nbsp;of the characters of the function key.<br>
- When using&nbsp;<span class="Special">&lt;F1&gt;</span>&nbsp;to&nbsp;<span class="Special">&lt;F4&gt;</span>&nbsp;the actual key code generated may correspond to<br>
&nbsp;&nbsp;<span class="Special">&lt;xF1&gt;</span>&nbsp;to&nbsp;<span class="Special">&lt;xF4&gt;</span>.&nbsp;&nbsp;There are mappings from&nbsp;<span class="Special">&lt;xF1&gt;</span>&nbsp;to&nbsp;<span class="Special">&lt;F1&gt;</span>,&nbsp;<span class="Special">&lt;xF2&gt;</span>&nbsp;to&nbsp;<span class="Special">&lt;F2&gt;</span>, etc.,<br>
&nbsp;&nbsp;but these are not recognized after another half a mapping.&nbsp;&nbsp;Make sure the<br>
&nbsp;&nbsp;key codes for&nbsp;<span class="Special">&lt;F1&gt;</span>&nbsp;to&nbsp;<span class="Special">&lt;F4&gt;</span>&nbsp;are correct:<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:set &lt;F1&gt;=&lt;type CTRL-V&gt;&lt;type F1&gt;</div>
&nbsp;&nbsp;Type the&nbsp;<span class="Special">&lt;F1&gt;</span>&nbsp;as four characters.&nbsp;&nbsp;The part after the &quot;=&quot; must be done with<br>
&nbsp;&nbsp;the actual keys, not the literal text.<br>
Another solution is to use the actual key code in the mapping for the second<br>
special key:<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:map &lt;F1&gt;&lt;Esc&gt;OP :echo &quot;yes&quot;&lt;CR&gt;</div>
Don't type a real&nbsp;<span class="Special">&lt;Esc&gt;</span>, Vim will recognize the key code and replace it with<br>
<span class="Special">&lt;F1&gt;</span>&nbsp;anyway.<br>
<br>
Another problem may be that when keeping ALT or Meta pressed the terminal<br>
prepends ESC instead of setting the 8th bit.&nbsp;&nbsp;See&nbsp;<a class="Identifier" href="map.html#:map-alt-keys">:map-alt-keys</a>.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#recursive_mapping" name="recursive_mapping">recursive_mapping</a><br>
If you include the&nbsp;<span class="Special">{lhs}</span>&nbsp;in the&nbsp;<span class="Special">{rhs}</span>&nbsp;you have a recursive mapping.&nbsp;&nbsp;When<br>
<span class="Special">{lhs}</span>&nbsp;is typed, it will be replaced with&nbsp;<span class="Special">{rhs}</span>.&nbsp;&nbsp;When the&nbsp;<span class="Special">{lhs}</span>&nbsp;which is<br>
included in&nbsp;<span class="Special">{rhs}</span>&nbsp;is encountered it will be replaced with&nbsp;<span class="Special">{rhs}</span>, and so on.<br>
This makes it possible to repeat a command an infinite number of times.&nbsp;&nbsp;The<br>
only problem is that the only way to stop this is by causing an error.&nbsp;&nbsp;The<br>
macros to solve a maze uses this, look there for an example.&nbsp;&nbsp;There is one<br>
exception: If the&nbsp;<span class="Special">{rhs}</span>&nbsp;starts with&nbsp;<span class="Special">{lhs}</span>, the first character is not mapped<br>
again (this is Vi compatible).<br>
For example:<br>
<div class="helpExample">&nbsp;&nbsp; :map ab abcd</div>
will execute the &quot;a&quot; command and insert &quot;bcd&quot; in the text.&nbsp;&nbsp;The &quot;ab&quot; in the<br>
<span class="Special">{rhs}</span>&nbsp;will not be mapped again.<br>
<br>
If you want to exchange the meaning of two keys you should use the :noremap<br>
command.&nbsp;&nbsp;For example:<br>
<div class="helpExample">&nbsp;&nbsp; :noremap k j<br>
&nbsp;&nbsp; :noremap j k</div>
This will exchange the cursor up and down commands.<br>
<br>
With the normal :map command, when the&nbsp;<a class="Type" href="options.html#'remap'">'remap'</a>&nbsp;option is on, mapping takes<br>
place until the text is found not to be a part of a&nbsp;<span class="Special">{lhs}</span>.&nbsp;&nbsp;For example, if<br>
you use:<br>
<div class="helpExample">&nbsp;&nbsp; :map x y<br>
&nbsp;&nbsp; :map y x</div>
Vim will replace x with y, and then y with x, etc.&nbsp;&nbsp;When this has happened<br>
<a class="Type" href="options.html#'maxmapdepth'">'maxmapdepth'</a>&nbsp;times (default 1000), Vim will give the error message<br>
&quot;recursive mapping&quot;.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:map-undo" name=":map-undo">:map-undo</a><br>
If you include an undo command inside a mapped sequence, this will bring the<br>
text back in the state before executing the macro.&nbsp;&nbsp;This is compatible with<br>
the original Vi, as long as there is only one undo command in the mapped<br>
sequence (having two undo commands in a mapped sequence did not make sense<br>
in the original Vi, you would get back the text before the first undo).<br>
<br>
<br>
1.10 MAPPING ALT-KEYS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:map-alt-keys" name=":map-alt-keys">:map-alt-keys</a><br>
<br>
In the GUI Vim handles the Alt key itself, thus mapping keys with ALT should<br>
always work.&nbsp;&nbsp;But in a terminal Vim gets a sequence of bytes and has to figure<br>
out whether ALT was pressed or not.<br>
<br>
By default Vim assumes that pressing the ALT key sets the 8th bit of a typed<br>
character.&nbsp;&nbsp;Most decent terminals can work that way, such as xterm, aterm and<br>
rxvt.&nbsp;&nbsp;If your&nbsp;<span class="Special">&lt;A-k&gt;</span>&nbsp;mappings don't work it might be that the terminal is<br>
prefixing the character with an ESC character.&nbsp;&nbsp;But you can just as well type<br>
ESC before a character, thus Vim doesn't know what happened (except for<br>
checking the delay between characters, which is not reliable).<br>
<br>
As of this writing, some mainstream terminals like gnome-terminal and konsole<br>
use the ESC prefix.&nbsp;&nbsp;There doesn't appear a way to have them use the 8th bit<br>
instead.&nbsp;&nbsp;Xterm should work well by default.&nbsp;&nbsp;Aterm and rxvt should work well<br>
when started with the &quot;--meta8&quot; argument.&nbsp;&nbsp;You can also tweak resources like<br>
&quot;metaSendsEscape&quot;, &quot;eightBitInput&quot; and &quot;eightBitOutput&quot;.<br>
<br>
On the Linux console, this behavior can be toggled with the &quot;setmetamode&quot;<br>
command.&nbsp;&nbsp;Bear in mind that not using an ESC prefix could get you in trouble<br>
with other programs.&nbsp;&nbsp;You should make sure that bash has the &quot;convert-meta&quot;<br>
option set to &quot;on&quot; in order for your Meta keybindings to still work on it<br>
(it's the default readline behavior, unless changed by specific system<br>
configuration).&nbsp;&nbsp;For that, you can add the line:<br>
<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set convert-meta on</div>
<br>
to your ~/.inputrc file. If you're creating the file, you might want to use:<br>
<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$include /etc/inputrc</div>
<br>
as the first line, if that file exists on your system, to keep global options.<br>
This may cause a problem for entering special characters, such as the umlaut.<br>
Then you should use&nbsp;<span class="Special">CTRL-V</span>&nbsp;before that character.<br>
<br>
Bear in mind that convert-meta has been reported to have troubles when used in<br>
UTF-8 locales.&nbsp;&nbsp;On terminals like xterm, the &quot;metaSendsEscape&quot; resource can be<br>
toggled on the fly through the &quot;Main Options&quot; menu, by pressing Ctrl-LeftClick<br>
on the terminal; that's a good last resource in case you want to send ESC when<br>
using other applications but not when inside Vim.<br>
<br>
<br>
1.11 MAPPING AN OPERATOR&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:map-operator" name=":map-operator">:map-operator</a><br>
<br>
An operator is used before a&nbsp;<span class="Special">{motion}</span>&nbsp;command.&nbsp;&nbsp;To define your own operator<br>
you must create mapping that first sets the&nbsp;<a class="Type" href="options.html#'operatorfunc'">'operatorfunc'</a>&nbsp;option and then<br>
invoke the&nbsp;<a class="Identifier" href="map.html#g@">g@</a>&nbsp;operator.&nbsp;&nbsp;After the user types the&nbsp;<span class="Special">{motion}</span>&nbsp;command the<br>
specified function will be called.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#g@" name="g@">g@</a>&nbsp;<a class="Constant" href="map.html#E774" name="E774">E774</a>&nbsp;<a class="Constant" href="map.html#E775" name="E775">E775</a><br>
g@<span class="Special">{motion}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Call the function set by the&nbsp;<a class="Type" href="options.html#'operatorfunc'">'operatorfunc'</a>&nbsp;option.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The '[ mark is positioned at the start of the text<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;moved over by&nbsp;<span class="Special">{motion}</span>, the '] mark on the last<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;character of the text.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The function is called with one String argument:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;line&quot;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="Special">{motion}</span>&nbsp;was&nbsp;<a class="Identifier" href="motion.html#linewise">linewise</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;char&quot;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="Special">{motion}</span>&nbsp;was&nbsp;<a class="Identifier" href="motion.html#characterwise">characterwise</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;block&quot;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="Special">{motion}</span>&nbsp;was&nbsp;<a class="Identifier" href="visual.html#blockwise-visual">blockwise-visual</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Although &quot;block&quot; would rarely appear, since it can<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;only result from Visual mode where &quot;g@&quot; is not useful.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="Special">{not available when compiled without the&nbsp;</span><a class="Identifier" href="various.html#+eval">+eval</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="Special">feature}</span><br>
<br>
Here is an example that counts the number of spaces with&nbsp;<span class="Special">&lt;F4&gt;</span>:<br>
<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nmap &lt;silent&gt; &lt;F4&gt; :set opfunc=CountSpaces&lt;CR&gt;g@<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;vmap &lt;silent&gt; &lt;F4&gt; :&lt;C-U&gt;call CountSpaces(visualmode(), 1)&lt;CR&gt;</div>
<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function! CountSpaces(type, ...)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;let sel_save = &amp;selection<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;let &amp;selection = &quot;inclusive&quot;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;let reg_save = @@</div>
<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if a:0&nbsp;&nbsp;&quot; Invoked from Visual mode, use gv command.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;silent exe &quot;normal! gvy&quot;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;elseif a:type == 'line'<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;silent exe &quot;normal! '[V']y&quot;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;silent exe &quot;normal! `[v`]y&quot;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;endif</div>
<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echomsg strlen(substitute(@@, '[^ ]', '', 'g'))</div>
<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;let &amp;selection = sel_save<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;let @@ = reg_save<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;endfunction</div>
<br>
<span class="Todo">Note</span>&nbsp;that the&nbsp;<a class="Type" href="options.html#'selection'">'selection'</a>&nbsp;option is temporarily set to &quot;inclusive&quot; to be able<br>
to yank exactly the right text by using Visual mode from the '[ to the ']<br>
mark.<br>
<br>
Also&nbsp;<span class="Todo">note</span>&nbsp;that there is a separate mapping for Visual mode.&nbsp;&nbsp;It removes the<br>
&quot;'&lt;,'&gt;&quot; range that &quot;:&quot; inserts in Visual mode and invokes the function with<br>
visualmode() and an extra argument.<br>
<br>
<span class="PreProc">==============================================================================</span><br>
2. Abbreviations&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#abbreviations" name="abbreviations">abbreviations</a>&nbsp;<a class="Constant" href="map.html#Abbreviations" name="Abbreviations">Abbreviations</a><br>
<br>
Abbreviations are used in Insert mode, Replace mode and Command-line mode.<br>
If you enter a word that is an abbreviation, it is replaced with the word it<br>
stands for.&nbsp;&nbsp;This can be used to save typing for often used long words.&nbsp;&nbsp;And<br>
you can use it to automatically correct obvious spelling errors.<br>
Examples:<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:iab ms Microsoft<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:iab tihs this<br>
<br>
There are three types of abbreviations:<br>
<br>
full-id&nbsp;&nbsp; The &quot;full-id&quot; type consists entirely of keyword characters (letters<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;and characters from&nbsp;<a class="Type" href="options.html#'iskeyword'">'iskeyword'</a>&nbsp;option).&nbsp;&nbsp;This is the most common<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;abbreviation.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Examples: &quot;foo&quot;, &quot;g3&quot;, &quot;-1&quot;<br>
<br>
end-id&nbsp;&nbsp;&nbsp;&nbsp;The &quot;end-id&quot; type ends in a keyword character, but all the other<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;characters are not keyword characters.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Examples: &quot;#i&quot;, &quot;..f&quot;, &quot;$/7&quot;<br>
<br>
non-id&nbsp;&nbsp;&nbsp;&nbsp;The &quot;non-id&quot; type ends in a non-keyword character, the other<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;characters may be of any type, excluding space and tab.&nbsp;&nbsp;{this type<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;is not supported by Vi}<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Examples: &quot;def#&quot;, &quot;4/7$&quot;<br>
<br>
Examples of strings that cannot be abbreviations: &quot;a.b&quot;, &quot;#def&quot;, &quot;a b&quot;, &quot;_$r&quot;<br>
<br>
An abbreviation is only recognized when you type a non-keyword character.<br>
This can also be the&nbsp;<span class="Special">&lt;Esc&gt;</span>&nbsp;that ends insert mode or the&nbsp;<span class="Special">&lt;CR&gt;</span>&nbsp;that ends a<br>
command.&nbsp;&nbsp;The non-keyword character which ends the abbreviation is inserted<br>
after the expanded abbreviation.&nbsp;&nbsp;An exception to this is the character&nbsp;<span class="Special">&lt;C-]&gt;</span>,<br>
which is used to expand an abbreviation without inserting any extra<br>
characters.<br>
<br>
Example:<br>
<div class="helpExample">&nbsp;&nbsp; :ab hh&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hello</div>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;hh<span class="Special">&lt;Space&gt;</span>&quot; is expanded to &quot;hello<span class="Special">&lt;Space&gt;</span>&quot;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;hh<span class="Special">&lt;C-]&gt;</span>&quot; is expanded to &quot;hello&quot;<br>
<br>
The characters before the cursor must match the abbreviation.&nbsp;&nbsp;Each type has<br>
an additional rule:<br>
<br>
full-id&nbsp;&nbsp; In front of the match is a non-keyword character, or this is where<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;the line or insertion starts.&nbsp;&nbsp;Exception: When the abbreviation is<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;only one character, it is not recognized if there is a non-keyword<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;character in front of it, other than a space or a tab.<br>
<br>
end-id&nbsp;&nbsp;&nbsp;&nbsp;In front of the match is a keyword character, or a space or a tab,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;or this is where the line or insertion starts.<br>
<br>
non-id&nbsp;&nbsp;&nbsp;&nbsp;In front of the match is a space, tab or the start of the line or<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;the insertion.<br>
<br>
Examples: (<span class="Special">{CURSOR}</span>&nbsp;is where you type a non-keyword character)<br>
<div class="helpExample">&nbsp;&nbsp; :ab foo&nbsp;&nbsp; four old otters</div>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot; foo<span class="Special">{CURSOR}</span>&quot;&nbsp;&nbsp;&nbsp;&nbsp;is expanded to &quot; four old otters&quot;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot; foobar<span class="Special">{CURSOR}</span>&quot; is not expanded<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;barfoo<span class="Special">{CURSOR}</span>&quot;&nbsp;&nbsp;is not expanded<br>
<br>
<div class="helpExample">&nbsp;&nbsp; :ab #i #include</div>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;#i<span class="Special">{CURSOR}</span>&quot;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;is expanded to &quot;#include&quot;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;&gt;#i<span class="Special">{CURSOR}</span>&quot;&nbsp;&nbsp;&nbsp;&nbsp; is not expanded<br>
<br>
<div class="helpExample">&nbsp;&nbsp; :ab ;; &lt;endofline&gt;</div>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;test;;&quot;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;is not expanded<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;test ;;&quot;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; is expanded to &quot;test&nbsp;<span class="Special">&lt;endofline&gt;</span>&quot;<br>
<br>
To avoid the abbreviation in Insert mode: Type&nbsp;<span class="Special">CTRL-V</span>&nbsp;before the character<br>
that would trigger the abbreviation.&nbsp;&nbsp;E.g.&nbsp;<span class="Special">CTRL-V</span>&nbsp;<span class="Special">&lt;Space&gt;</span>.&nbsp;&nbsp;Or type part of<br>
the abbreviation, exit insert mode with&nbsp;<span class="Special">&lt;Esc&gt;</span>, re-enter insert mode with &quot;a&quot;<br>
and type the rest.<br>
<br>
To avoid the abbreviation in Command-line mode: Type&nbsp;<span class="Special">CTRL-V</span>&nbsp;twice somewhere in<br>
the abbreviation to avoid it to be replaced.&nbsp;&nbsp;A&nbsp;<span class="Special">CTRL-V</span>&nbsp;in front of a normal<br>
character is mostly ignored otherwise.<br>
<br>
It is possible to move the cursor after an abbreviation:<br>
<div class="helpExample">&nbsp;&nbsp; :iab if if ()&lt;Left&gt;</div>
This does not work if&nbsp;<a class="Type" href="options.html#'cpoptions'">'cpoptions'</a>&nbsp;includes the '&lt;' flag.&nbsp;<a class="Identifier" href="intro.html#<>">&lt;&gt;</a><br>
<br>
You can even do more complicated things.&nbsp;&nbsp;For example, to consume the space<br>
typed after an abbreviation:<br>
<div class="helpExample">&nbsp;&nbsp; func Eatchar(pat)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;let c = nr2char(getchar(0))<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return (c =~ a:pat) ? '' : c<br>
&nbsp;&nbsp; endfunc<br>
&nbsp;&nbsp; iabbr &lt;silent&gt; if if ()&lt;Left&gt;&lt;C-R&gt;=Eatchar('\s')&lt;CR&gt;</div>
<br>
There are no default abbreviations.<br>
<br>
Abbreviations are never recursive.&nbsp;&nbsp;You can use &quot;:ab f f-o-o&quot; without any<br>
problem.&nbsp;&nbsp;But abbreviations can be mapped.&nbsp;&nbsp;{some versions of Vi support<br>
recursive abbreviations, for no apparent reason}<br>
<br>
Abbreviations are disabled if the&nbsp;<a class="Type" href="options.html#'paste'">'paste'</a>&nbsp;option is on.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:abbreviate-local" name=":abbreviate-local">:abbreviate-local</a>&nbsp;<a class="Constant" href="map.html#:abbreviate-<buffer>" name=":abbreviate-&lt;buffer&gt;">:abbreviate-&lt;buffer&gt;</a><br>
Just like mappings, abbreviations can be local to a buffer.&nbsp;&nbsp;This is mostly<br>
used in a&nbsp;<a class="Identifier" href="usr_43.html#filetype-plugin">filetype-plugin</a>&nbsp;file.&nbsp;&nbsp;Example for a C plugin file:<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:abb &lt;buffer&gt; FF&nbsp;&nbsp;for (i = 0; i &lt; ; ++i)</div>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:ab" name=":ab">:ab</a>&nbsp;<a class="Constant" href="map.html#:abbreviate" name=":abbreviate">:abbreviate</a><br>
:ab[breviate]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; list all abbreviations.&nbsp;&nbsp;The character in the first<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;column indicates the mode where the abbreviation is<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;used: 'i' for insert mode, 'c' for Command-line<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mode, '!' for both.&nbsp;&nbsp;These are the same as for<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mappings, see&nbsp;<a class="Identifier" href="map.html#map-listing">map-listing</a>.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:abbreviate-verbose" name=":abbreviate-verbose">:abbreviate-verbose</a><br>
When&nbsp;<a class="Type" href="options.html#'verbose'">'verbose'</a>&nbsp;is non-zero, listing an abbreviation will also display where it<br>
was last defined.&nbsp;&nbsp;Example:<br>
<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:verbose abbreviate<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;!&nbsp;&nbsp;teh&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; the<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Last set from /home/abcd/vim/abbr.vim</div>
<br>
See&nbsp;<a class="Identifier" href="various.html#:verbose-cmd">:verbose-cmd</a>&nbsp;for more information.<br>
<br>
:ab[breviate]&nbsp;<span class="Special">{lhs}</span>&nbsp;&nbsp;&nbsp;&nbsp; list the abbreviations that start with&nbsp;<span class="Special">{lhs}</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;You may need to insert a&nbsp;<span class="Special">CTRL-V</span>&nbsp;(type it twice) to<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;avoid that a typed&nbsp;<span class="Special">{lhs}</span>&nbsp;is expanded, since<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;command-line abbreviations apply here.<br>
<br>
:ab[breviate] [<span class="Special">&lt;expr&gt;</span>] [<span class="Special">&lt;buffer&gt;</span>]&nbsp;<span class="Special">{lhs}</span>&nbsp;<span class="Special">{rhs}</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;add abbreviation for&nbsp;<span class="Special">{lhs}</span>&nbsp;to&nbsp;<span class="Special">{rhs}</span>.&nbsp;&nbsp;If&nbsp;<span class="Special">{lhs}</span>&nbsp;already<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;existed it is replaced with the new&nbsp;<span class="Special">{rhs}</span>.&nbsp;&nbsp;<span class="Special">{rhs}</span>&nbsp;may<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;contain spaces.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;See&nbsp;<a class="Identifier" href="map.html#:map-<expr>">:map-&lt;expr&gt;</a>&nbsp;for the optional&nbsp;<span class="Special">&lt;expr&gt;</span>&nbsp;argument.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;See&nbsp;<a class="Identifier" href="map.html#:map-<buffer>">:map-&lt;buffer&gt;</a>&nbsp;for the optional&nbsp;<span class="Special">&lt;buffer&gt;</span>&nbsp;argument.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:una" name=":una">:una</a>&nbsp;<a class="Constant" href="map.html#:unabbreviate" name=":unabbreviate">:unabbreviate</a><br>
:una[bbreviate]&nbsp;<span class="Special">{lhs}</span>&nbsp;&nbsp; Remove abbreviation for&nbsp;<span class="Special">{lhs}</span>&nbsp;from the list.&nbsp;&nbsp;If none<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;is found, remove abbreviations in which&nbsp;<span class="Special">{lhs}</span>&nbsp;matches<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;with the&nbsp;<span class="Special">{rhs}</span>.&nbsp;&nbsp;This is done so that you can even<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;remove abbreviations after expansion.&nbsp;&nbsp;To avoid<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;expansion insert a&nbsp;<span class="Special">CTRL-V</span>&nbsp;(type it twice).<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:norea" name=":norea">:norea</a>&nbsp;<a class="Constant" href="map.html#:noreabbrev" name=":noreabbrev">:noreabbrev</a><br>
:norea[bbrev] [<span class="Special">&lt;expr&gt;</span>] [<span class="Special">&lt;buffer&gt;</span>]&nbsp;<span class="Special">[lhs]</span>&nbsp;<span class="Special">[rhs]</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;same as &quot;:ab&quot;, but no remapping for this&nbsp;<span class="Special">{rhs}</span>&nbsp;<span class="Special">{not</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="Special">in Vi}</span><br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:ca" name=":ca">:ca</a>&nbsp;<a class="Constant" href="map.html#:cabbrev" name=":cabbrev">:cabbrev</a><br>
:ca[bbrev] [<span class="Special">&lt;expr&gt;</span>] [<span class="Special">&lt;buffer&gt;</span>]&nbsp;<span class="Special">[lhs]</span>&nbsp;<span class="Special">[rhs]</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;same as &quot;:ab&quot;, but for Command-line mode only.&nbsp;&nbsp;<span class="Special">{not</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="Special">in Vi}</span><br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:cuna" name=":cuna">:cuna</a>&nbsp;<a class="Constant" href="map.html#:cunabbrev" name=":cunabbrev">:cunabbrev</a><br>
:cuna[bbrev]&nbsp;<span class="Special">{lhs}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;same as &quot;:una&quot;, but for Command-line mode only.&nbsp;&nbsp;<span class="Special">{not</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="Special">in Vi}</span><br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:cnorea" name=":cnorea">:cnorea</a>&nbsp;<a class="Constant" href="map.html#:cnoreabbrev" name=":cnoreabbrev">:cnoreabbrev</a><br>
:cnorea[bbrev] [<span class="Special">&lt;expr&gt;</span>] [<span class="Special">&lt;buffer&gt;</span>]&nbsp;<span class="Special">[lhs]</span>&nbsp;<span class="Special">[rhs]</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;same as &quot;:ab&quot;, but for Command-line mode only and no<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;remapping for this&nbsp;<span class="Special">{rhs}</span>&nbsp;<span class="Special">{not in Vi}</span><br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:ia" name=":ia">:ia</a>&nbsp;<a class="Constant" href="map.html#:iabbrev" name=":iabbrev">:iabbrev</a><br>
:ia[bbrev] [<span class="Special">&lt;expr&gt;</span>] [<span class="Special">&lt;buffer&gt;</span>]&nbsp;<span class="Special">[lhs]</span>&nbsp;<span class="Special">[rhs]</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;same as &quot;:ab&quot;, but for Insert mode only.&nbsp;&nbsp;<span class="Special">{not in Vi}</span><br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:iuna" name=":iuna">:iuna</a>&nbsp;<a class="Constant" href="map.html#:iunabbrev" name=":iunabbrev">:iunabbrev</a><br>
:iuna[bbrev]&nbsp;<span class="Special">{lhs}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;same as &quot;:una&quot;, but for insert mode only.&nbsp;&nbsp;<span class="Special">{not in</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="Special">Vi}</span><br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:inorea" name=":inorea">:inorea</a>&nbsp;<a class="Constant" href="map.html#:inoreabbrev" name=":inoreabbrev">:inoreabbrev</a><br>
:inorea[bbrev] [<span class="Special">&lt;expr&gt;</span>] [<span class="Special">&lt;buffer&gt;</span>]&nbsp;<span class="Special">[lhs]</span>&nbsp;<span class="Special">[rhs]</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;same as &quot;:ab&quot;, but for Insert mode only and no<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;remapping for this&nbsp;<span class="Special">{rhs}</span>&nbsp;<span class="Special">{not in Vi}</span><br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:abc" name=":abc">:abc</a>&nbsp;<a class="Constant" href="map.html#:abclear" name=":abclear">:abclear</a><br>
:abc[lear] [<span class="Special">&lt;buffer&gt;</span>]&nbsp;&nbsp; Remove all abbreviations.&nbsp;&nbsp;<span class="Special">{not in Vi}</span><br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:iabc" name=":iabc">:iabc</a>&nbsp;<a class="Constant" href="map.html#:iabclear" name=":iabclear">:iabclear</a><br>
:iabc[lear] [<span class="Special">&lt;buffer&gt;</span>]&nbsp;&nbsp;Remove all abbreviations for Insert mode.&nbsp;&nbsp;<span class="Special">{not in Vi}</span><br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:cabc" name=":cabc">:cabc</a>&nbsp;<a class="Constant" href="map.html#:cabclear" name=":cabclear">:cabclear</a><br>
:cabc[lear] [<span class="Special">&lt;buffer&gt;</span>]&nbsp;&nbsp;Remove all abbreviations for Command-line mode.&nbsp;&nbsp;<span class="Special">{not</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="Special">in Vi}</span><br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#using_CTRL-V" name="using_CTRL-V">using_CTRL-V</a><br>
It is possible to use special characters in the rhs of an abbreviation.<br>
<span class="Special">CTRL-V</span>&nbsp;has to be used to avoid the special meaning of most non printable<br>
characters.&nbsp;&nbsp;How many&nbsp;<span class="Special">CTRL-V</span>s need to be typed depends on how you enter the<br>
abbreviation.&nbsp;&nbsp;This also applies to mappings.&nbsp;&nbsp;Let's use an example here.<br>
<br>
Suppose you want to abbreviate &quot;esc&quot; to enter an&nbsp;<span class="Special">&lt;Esc&gt;</span>&nbsp;character.&nbsp;&nbsp;When you<br>
type the &quot;:ab&quot; command in Vim, you have to enter this: (here ^V is a&nbsp;<span class="Special">CTRL-V</span><br>
and ^[ is&nbsp;<span class="Special">&lt;Esc&gt;</span>)<br>
<br>
You type:&nbsp;&nbsp; ab esc ^V^V^V^V^V^[<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;All keyboard input is subjected to ^V quote interpretation, so<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;the first, third, and fifth ^V&nbsp;&nbsp;characters simply allow the second,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;and fourth ^Vs, and the ^[, to be entered into the command-line.<br>
<br>
You see:&nbsp;&nbsp;&nbsp;&nbsp;ab esc ^V^V^[<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The command-line contains two actual ^Vs before the ^[.&nbsp;&nbsp;This is<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;how it should appear in your .exrc file, if you choose to go that<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;route.&nbsp;&nbsp;The first ^V is there to quote the second ^V; the :ab<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;command uses ^V as its own quote character, so you can include quoted<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;whitespace or the | character in the abbreviation.&nbsp;&nbsp;The :ab command<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;doesn't do anything special with the ^[ character, so it doesn't need<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;to be quoted.&nbsp;&nbsp;(Although quoting isn't harmful; that's why typing 7<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[but not 8!] ^Vs works.)<br>
<br>
Stored as:&nbsp;&nbsp;esc&nbsp;&nbsp;&nbsp;&nbsp; ^V^[<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;After parsing, the abbreviation's short form (&quot;esc&quot;) and long form<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(the two characters &quot;^V^[&quot;) are stored in the abbreviation table.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If you give the :ab command with no arguments, this is how the<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;abbreviation will be displayed.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Later, when the abbreviation is expanded because the user typed in<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;the word &quot;esc&quot;, the long form is subjected to the same type of<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;^V interpretation as keyboard input.&nbsp;&nbsp;So the ^V protects the ^[<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;character from being interpreted as the &quot;exit Insert mode&quot; character.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Instead, the ^[ is inserted into the text.<br>
<br>
Expands to: ^[<br>
<br>
[example given by Steve Kirkendall]<br>
<br>
<span class="PreProc">==============================================================================</span><br>
3. Local mappings and functions&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#script-local" name="script-local">script-local</a><br>
<br>
When using several Vim script files, there is the danger that mappings and<br>
functions used in one script use the same name as in other scripts.&nbsp;&nbsp;To avoid<br>
this, they can be made local to the script.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#<SID>" name="&lt;SID&gt;">&lt;SID&gt;</a>&nbsp;<a class="Constant" href="map.html#<SNR>" name="&lt;SNR&gt;">&lt;SNR&gt;</a>&nbsp;<a class="Constant" href="map.html#E81" name="E81">E81</a><br>
The string &quot;<span class="Special">&lt;SID&gt;</span>&quot; can be used in a mapping or menu.&nbsp;&nbsp;This requires that the<br>
'&lt;' flag is not present in&nbsp;<a class="Type" href="options.html#'cpoptions'">'cpoptions'</a>.<br>
&nbsp;&nbsp; When executing the map command, Vim will replace &quot;<span class="Special">&lt;SID&gt;</span>&quot; with the special<br>
key code&nbsp;<span class="Special">&lt;SNR&gt;</span>, followed by a number that's unique for the script, and an<br>
underscore.&nbsp;&nbsp;Example:<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:map &lt;SID&gt;Add</div>
could define a mapping &quot;<span class="Special">&lt;SNR&gt;</span>23_Add&quot;.<br>
<br>
When defining a function in a script, &quot;s:&quot; can be prepended to the name to<br>
make it local to the script.&nbsp;&nbsp;But when a mapping is executed from outside of<br>
the script, it doesn't know in which script the function was defined.&nbsp;&nbsp;To<br>
avoid this problem, use &quot;<span class="Special">&lt;SID&gt;</span>&quot; instead of &quot;s:&quot;.&nbsp;&nbsp;The same translation is done<br>
as for mappings.&nbsp;&nbsp;This makes it possible to define a call to the function in<br>
a mapping.<br>
<br>
When a local function is executed, it runs in the context of the script it was<br>
defined in.&nbsp;&nbsp;This means that new functions and mappings it defines can also<br>
use &quot;s:&quot; or &quot;<span class="Special">&lt;SID&gt;</span>&quot; and it will use the same unique number as when the<br>
function itself was defined.&nbsp;&nbsp;Also, the &quot;s:var&quot; local script variables can be<br>
used.<br>
<br>
When executing an autocommand or a user command, it will run in the context of<br>
the script it was defined in.&nbsp;&nbsp;This makes it possible that the command calls a<br>
local function or uses a local mapping.<br>
<br>
Otherwise, using &quot;<span class="Special">&lt;SID&gt;</span>&quot; outside of a script context is an error.<br>
<br>
If you need to get the script number to use in a complicated script, you can<br>
use this function:<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function s:SID()<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return matchstr(expand('&lt;sfile&gt;'), '&lt;SNR&gt;\zs\d\+\ze_SID$')<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;endfun</div>
<br>
The &quot;<span class="Special">&lt;SNR&gt;</span>&quot; will be shown when listing functions and mappings.&nbsp;&nbsp;This is useful<br>
to find out what they are defined to.<br>
<br>
The&nbsp;<a class="Identifier" href="repeat.html#:scriptnames">:scriptnames</a>&nbsp;command can be used to see which scripts have been sourced<br>
and what their&nbsp;<span class="Special">&lt;SNR&gt;</span>&nbsp;number is.<br>
<br>
This is all&nbsp;<span class="Special">{not in Vi}</span>&nbsp;and&nbsp;<span class="Special">{not available when compiled without the&nbsp;</span><a class="Identifier" href="various.html#+eval">+eval</a><br>
<span class="Special">feature}</span>.<br>
<br>
<span class="PreProc">==============================================================================</span><br>
4. User-defined commands&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#user-commands" name="user-commands">user-commands</a><br>
<br>
It is possible to define your own Ex commands.&nbsp;&nbsp;A user-defined command can act<br>
just like a built-in command (it can have a range or arguments, arguments can<br>
be completed as filenames or buffer names, etc), except that when the command<br>
is executed, it is transformed into a normal Ex command and then executed.<br>
<br>
For starters: See section&nbsp;<a class="Identifier" href="usr_40.html#40.2">40.2</a>&nbsp;in the user manual.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#E183" name="E183">E183</a>&nbsp;<a class="Constant" href="map.html#E841" name="E841">E841</a>&nbsp;<a class="Constant" href="map.html#user-cmd-ambiguous" name="user-cmd-ambiguous">user-cmd-ambiguous</a><br>
All user defined commands must start with an uppercase letter, to avoid<br>
confusion with builtin commands.&nbsp;&nbsp;Exceptions are these builtin commands:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:Next<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:X<br>
They cannot be used for a user defined command.&nbsp;&nbsp;&quot;:Print&quot; is also an existing<br>
command, but it is deprecated and can be overruled.<br>
<br>
The other characters of the user command can be uppercase letters, lowercase<br>
letters or digits.&nbsp;&nbsp;When using digits,&nbsp;<span class="Todo">note</span>&nbsp;that other commands that take a<br>
numeric argument may become ambiguous.&nbsp;&nbsp;For example, the command &quot;:Cc2&quot; could<br>
be the user command &quot;:Cc2&quot; without an argument, or the command &quot;:Cc&quot; with<br>
argument &quot;2&quot;.&nbsp;&nbsp;It is advised to put a space between the command name and the<br>
argument to avoid these problems.<br>
<br>
When using a user-defined command, the command can be abbreviated.&nbsp;&nbsp;However, if<br>
an abbreviation is not unique, an error will be issued.&nbsp;&nbsp;Furthermore, a<br>
built-in command will always take precedence.<br>
<br>
Example:<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:command Rename ...<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:command Renumber ...<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:Rena&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot; Means &quot;Rename&quot;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:Renu&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot; Means &quot;Renumber&quot;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:Ren&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot; Error - ambiguous<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:command Paste ...<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:P&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot; The built-in :Print</div>
<br>
It is recommended that full names for user-defined commands are used in<br>
scripts.<br>
<br>
:com[mand]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:com" name=":com">:com</a>&nbsp;<a class="Constant" href="map.html#:command" name=":command">:command</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;List all user-defined commands.&nbsp;&nbsp;When listing commands,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;the characters in the first two columns are<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;!&nbsp;&nbsp; Command has the -bang attribute<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;&nbsp;&nbsp; Command has the -register attribute<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;b&nbsp;&nbsp; Command is local to current buffer<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(see below for details on attributes)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The list can be filtered on command name with<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="various.html#:filter">:filter</a>, e.g., to list all commands with &quot;Pyth&quot; in<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;the name:<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;filter Pyth command</div>
<br>
:com[mand]&nbsp;<span class="Special">{cmd}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;List the user-defined commands that start with&nbsp;<span class="Special">{cmd}</span><br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:command-verbose" name=":command-verbose">:command-verbose</a><br>
When&nbsp;<a class="Type" href="options.html#'verbose'">'verbose'</a>&nbsp;is non-zero, listing a command will also display where it was<br>
last defined. Example:<br>
<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp;:verbose command TOhtml</div>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="PreProc">Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Args Range Complete&nbsp;&nbsp;Definition</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="PreProc">TOhtml&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;%&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :call Convert2HTML(&lt;line1&gt;, &lt;line2&gt;)</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="PreProc">Last set from /usr/share/vim/vim-7.0/plugin/tohtml.vim</span><br>
<br>
See&nbsp;<a class="Identifier" href="various.html#:verbose-cmd">:verbose-cmd</a>&nbsp;for more information.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#E174" name="E174">E174</a>&nbsp;<a class="Constant" href="map.html#E182" name="E182">E182</a><br>
:com[mand][!] [<span class="Special">{attr}</span>...]&nbsp;<span class="Special">{cmd}</span>&nbsp;<span class="Special">{rep}</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Define a user command.&nbsp;&nbsp;The name of the command is<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="Special">{cmd}</span>&nbsp;and its replacement text is&nbsp;<span class="Special">{rep}</span>.&nbsp;&nbsp;The command's<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;attributes (see below) are&nbsp;<span class="Special">{attr}</span>.&nbsp;&nbsp;If the command<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;already exists, an error is reported, unless a ! is<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;specified, in which case the command is redefined.<br>
<br>
:delc[ommand]&nbsp;<span class="Special">{cmd}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:delc" name=":delc">:delc</a>&nbsp;<a class="Constant" href="map.html#:delcommand" name=":delcommand">:delcommand</a>&nbsp;<a class="Constant" href="map.html#E184" name="E184">E184</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Delete the user-defined command&nbsp;<span class="Special">{cmd}</span>.<br>
<br>
:comc[lear]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:comc" name=":comc">:comc</a>&nbsp;<a class="Constant" href="map.html#:comclear" name=":comclear">:comclear</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Delete all user-defined commands.<br>
<br>
Command attributes<br>
<br>
User-defined commands are treated by Vim just like any other Ex commands.&nbsp;&nbsp;They<br>
can have arguments, or have a range specified.&nbsp;&nbsp;Arguments are subject to<br>
completion as filenames, buffers, etc.&nbsp;&nbsp;Exactly how this works depends upon the<br>
command's attributes, which are specified when the command is defined.<br>
<br>
There are a number of attributes, split into four categories: argument<br>
handling, completion behavior, range handling, and special cases.&nbsp;&nbsp;The<br>
attributes are described below, by category.<br>
<br>
Argument handling&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#E175" name="E175">E175</a>&nbsp;<a class="Constant" href="map.html#E176" name="E176">E176</a>&nbsp;<a class="Constant" href="map.html#:command-nargs" name=":command-nargs">:command-nargs</a><br>
<br>
By default, a user defined command will take no arguments (and an error is<br>
reported if any are supplied).&nbsp;&nbsp;However, it is possible to specify that the<br>
command can take arguments, using the -nargs attribute.&nbsp;&nbsp;Valid cases are:<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-nargs=0&nbsp;&nbsp;&nbsp;&nbsp;No arguments are allowed (the default)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-nargs=1&nbsp;&nbsp;&nbsp;&nbsp;Exactly one argument is required, it includes spaces&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-nargs=*&nbsp;&nbsp;&nbsp;&nbsp;Any number of arguments are allowed (0, 1, or many),<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;separated by white space<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-nargs=?&nbsp;&nbsp;&nbsp;&nbsp;0 or 1 arguments are allowed<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-nargs=+&nbsp;&nbsp;&nbsp;&nbsp;Arguments must be supplied, but any number are allowed<br>
<br>
Arguments are considered to be separated by (unescaped) spaces or tabs in this<br>
context, except when there is one argument, then the white space is part of<br>
the argument.<br>
<br>
<span class="Todo">Note</span>&nbsp;that arguments are used as text, not as expressions.&nbsp;&nbsp;Specifically,<br>
&quot;s:var&quot; will use the script-local variable in the script where the command was<br>
defined, not where it is invoked!&nbsp;&nbsp;Example:<br>
&nbsp;&nbsp;&nbsp;&nbsp;script1.vim:<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:let s:error = &quot;None&quot;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:command -nargs=1 Error echoerr &lt;args&gt;</div>
&nbsp;&nbsp;&nbsp; script2.vim:<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:source script1.vim<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:let s:error = &quot;Wrong!&quot;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:Error s:error</div>
Executing script2.vim will result in &quot;None&quot; being echoed.&nbsp;&nbsp;Not what you<br>
intended!&nbsp;&nbsp;Calling a function may be an alternative.<br>
<br>
Completion behavior&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:command-completion" name=":command-completion">:command-completion</a>&nbsp;<a class="Constant" href="map.html#E179" name="E179">E179</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#E180" name="E180">E180</a>&nbsp;<a class="Constant" href="map.html#E181" name="E181">E181</a>&nbsp;<a class="Constant" href="map.html#:command-complete" name=":command-complete">:command-complete</a><br>
By default, the arguments of user defined commands do not undergo completion.<br>
However, by specifying one or the other of the following attributes, argument<br>
completion can be enabled:<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-complete=augroup&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; autocmd groups<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-complete=buffer&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;buffer names<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-complete=behave&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:behave suboptions<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-complete=color&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; color schemes<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-complete=command&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Ex command (and arguments)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-complete=compiler&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;compilers<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-complete=cscope&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="if_cscop.html#:cscope">:cscope</a>&nbsp;suboptions<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-complete=dir&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; directory names<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-complete=environment&nbsp;&nbsp; environment variable names<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-complete=event&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; autocommand events<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-complete=expression&nbsp;&nbsp;&nbsp;&nbsp;Vim expression<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-complete=file&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;file and directory names<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-complete=file_in_path&nbsp;&nbsp;file and directory names in&nbsp;<a class="Identifier" href="options.html#'path'">'path'</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-complete=filetype&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;filetype names&nbsp;<a class="Identifier" href="options.html#'filetype'">'filetype'</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-complete=function&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function name<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-complete=help&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;help subjects<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-complete=highlight&nbsp;&nbsp;&nbsp;&nbsp; highlight groups<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-complete=history&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :history suboptions<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-complete=locale&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;locale names (as output of locale -a)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-complete=mapclear&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;buffer argument<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-complete=mapping&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mapping name<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-complete=menu&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;menus<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-complete=messages&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="message.html#:messages">:messages</a>&nbsp;suboptions<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-complete=option&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;options<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-complete=packadd&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; optional package&nbsp;<a class="Identifier" href="repeat.html#pack-add">pack-add</a>&nbsp;names<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-complete=shellcmd&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Shell command<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-complete=sign&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="sign.html#:sign">:sign</a>&nbsp;suboptions<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-complete=syntax&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;syntax file names&nbsp;<a class="Identifier" href="options.html#'syntax'">'syntax'</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-complete=syntime&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="syntax.html#:syntime">:syntime</a>&nbsp;suboptions<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-complete=tag&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tags<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-complete=tag_listfiles tags, file names are shown when&nbsp;<span class="Special">CTRL-D</span>&nbsp;is hit<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-complete=user&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;user names<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-complete=var&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; user variables<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-complete=custom,<span class="Special">{func}</span>&nbsp;custom completion, defined via&nbsp;<span class="Special">{func}</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-complete=customlist,<span class="Special">{func}</span>&nbsp;custom completion, defined via&nbsp;<span class="Special">{func}</span><br>
<br>
<span class="Todo">Note</span>: That some completion methods might expand environment variables.<br>
<br>
<br>
Custom completion&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:command-completion-custom" name=":command-completion-custom">:command-completion-custom</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:command-completion-customlist" name=":command-completion-customlist">:command-completion-customlist</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#E467" name="E467">E467</a>&nbsp;<a class="Constant" href="map.html#E468" name="E468">E468</a><br>
It is possible to define customized completion schemes via the &quot;custom,<span class="Special">{func}</span>&quot;<br>
or the &quot;customlist,<span class="Special">{func}</span>&quot; completion argument.&nbsp;&nbsp;The&nbsp;<span class="Special">{func}</span>&nbsp;part should be a<br>
function with the following signature:<br>
<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:function {func}(ArgLead, CmdLine, CursorPos)</div>
<br>
The function need not use all these arguments. The function should provide the<br>
completion candidates as the return value.<br>
<br>
For the &quot;custom&quot; argument, the function should return the completion<br>
candidates one per line in a newline separated string.<br>
<br>
For the &quot;customlist&quot; argument, the function should return the completion<br>
candidates as a Vim List.&nbsp;&nbsp;Non-string items in the list are ignored.<br>
<br>
The function arguments are:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ArgLead&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; the leading portion of the argument currently being<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;completed on<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CmdLine&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; the entire command line<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CursorPos&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; the cursor position in it (byte index)<br>
The function may use these for determining context.&nbsp;&nbsp;For the &quot;custom&quot;<br>
argument, it is not necessary to filter candidates against the (implicit<br>
pattern in) ArgLead.&nbsp;&nbsp;Vim will filter the candidates with its regexp engine<br>
after function return, and this is probably more efficient in most cases. For<br>
the &quot;customlist&quot; argument, Vim will not filter the returned completion<br>
candidates and the user supplied function should filter the candidates.<br>
<br>
The following example lists user names to a Finger command<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp;:com -complete=custom,ListUsers -nargs=1 Finger !finger &lt;args&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;:fun ListUsers(A,L,P)<br>
&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;&nbsp;&nbsp;&nbsp;return system(&quot;cut -d: -f1 /etc/passwd&quot;)<br>
&nbsp;&nbsp;&nbsp;&nbsp;:endfun</div>
<br>
The following example completes filenames from the directories specified in<br>
the&nbsp;<a class="Type" href="options.html#'path'">'path'</a>&nbsp;option:<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp;:com -nargs=1 -bang -complete=customlist,EditFileComplete<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\ EditFile edit&lt;bang&gt; &lt;args&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;:fun EditFileComplete(A,L,P)<br>
&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;&nbsp;&nbsp;&nbsp;return split(globpath(&amp;path, a:A), &quot;\n&quot;)<br>
&nbsp;&nbsp;&nbsp;&nbsp;:endfun</div>
<br>
This example does not work for file names with spaces!<br>
<br>
<br>
Range handling&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#E177" name="E177">E177</a>&nbsp;<a class="Constant" href="map.html#E178" name="E178">E178</a>&nbsp;<a class="Constant" href="map.html#:command-range" name=":command-range">:command-range</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:command-count" name=":command-count">:command-count</a><br>
By default, user-defined commands do not accept a line number range.&nbsp;&nbsp;However,<br>
it is possible to specify that the command does take a range (the -range<br>
attribute), or that it takes an arbitrary count value, either in the line<br>
number position (-range=<span class="Special">N</span>, like the&nbsp;<a class="Identifier" href="windows.html#:split">:split</a>&nbsp;command) or as a &quot;count&quot;<br>
argument (-count=<span class="Special">N</span>, like the&nbsp;<a class="Identifier" href="editing.html#:Next">:Next</a>&nbsp;command).&nbsp;&nbsp;The count will then be<br>
available in the argument with&nbsp;<a class="Identifier" href="map.html#<count>">&lt;count&gt;</a>.<br>
<br>
Possible attributes are:<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-range&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Range allowed, default is current line<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-range=%&nbsp;&nbsp;&nbsp;&nbsp;Range allowed, default is whole file (1,$)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-range=<span class="Special">N</span>&nbsp;&nbsp;&nbsp;&nbsp;A count (default&nbsp;<span class="Special">N</span>) which is specified in the line<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;number position (like&nbsp;<a class="Identifier" href="windows.html#:split">:split</a>); allows for zero line<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;number.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-count=<span class="Special">N</span>&nbsp;&nbsp;&nbsp;&nbsp;A count (default&nbsp;<span class="Special">N</span>) which is specified either in the line<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;number position, or as an initial argument (like&nbsp;<a class="Identifier" href="editing.html#:Next">:Next</a>).<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Specifying -count (without a default) acts like -count=0<br>
<br>
<span class="Todo">Note</span>&nbsp;that -range=<span class="Special">N</span>&nbsp;and -count=<span class="Special">N</span>&nbsp;are mutually exclusive - only one should be<br>
specified.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:command-addr" name=":command-addr">:command-addr</a><br>
It is possible that the special characters in the range like ., $ or % which<br>
by default correspond to the current line, last line and the whole buffer,<br>
relate to arguments, (loaded) buffers, windows or tab pages.<br>
<br>
Possible values are:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-addr=lines&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Range of lines (this is the default)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-addr=arguments&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Range for arguments<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-addr=buffers&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Range for buffers (also not loaded buffers)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-addr=loaded_buffers&nbsp;&nbsp;&nbsp;&nbsp;Range for loaded buffers<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-addr=windows&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Range for windows<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-addr=tabs&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Range for tab pages<br>
<br>
Special cases&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:command-bang" name=":command-bang">:command-bang</a>&nbsp;<a class="Constant" href="map.html#:command-bar" name=":command-bar">:command-bar</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#:command-register" name=":command-register">:command-register</a>&nbsp;<a class="Constant" href="map.html#:command-buffer" name=":command-buffer">:command-buffer</a><br>
There are some special cases as well:<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-bang&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; The command can take a ! modifier (like :q or :w)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-bar&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The command can be followed by a &quot;|&quot; and another command.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;A &quot;|&quot; inside the command argument is not allowed then.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Also checks for a &quot; to start a comment.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-register&nbsp;&nbsp; The first argument to the command can be an optional<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;register name (like :del, :put, :yank).<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-buffer&nbsp;&nbsp;&nbsp;&nbsp; The command will only be available in the current buffer.<br>
<br>
In the cases of the -count and -register attributes, if the optional argument<br>
is supplied, it is removed from the argument list and is available to the<br>
replacement text separately.<br>
<span class="Todo">Note</span>&nbsp;that these arguments can be abbreviated, but that is a deprecated<br>
feature.&nbsp;&nbsp;Use the full name for new scripts.<br>
<br>
Replacement text<br>
<br>
The replacement text for a user defined command is scanned for special escape<br>
sequences, using &lt;...&gt; notation.&nbsp;&nbsp;Escape sequences are replaced with values<br>
from the entered command line, and all other text is copied unchanged.&nbsp;&nbsp;The<br>
resulting string is executed as an Ex command.&nbsp;&nbsp;To avoid the replacement use<br>
<span class="Special">&lt;lt&gt;</span>&nbsp;in place of the initial &lt;.&nbsp;&nbsp;Thus to include &quot;<span class="Special">&lt;bang&gt;</span>&quot; literally use<br>
&quot;<span class="Special">&lt;lt&gt;</span>bang&gt;&quot;.<br>
<br>
The valid escape sequences are<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#<line1>" name="&lt;line1&gt;">&lt;line1&gt;</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="Special">&lt;line1&gt;</span>&nbsp;The starting line of the command range.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#<line2>" name="&lt;line2&gt;">&lt;line2&gt;</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="Special">&lt;line2&gt;</span>&nbsp;The final line of the command range.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#<count>" name="&lt;count&gt;">&lt;count&gt;</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="Special">&lt;count&gt;</span>&nbsp;Any count supplied (as described for the '-range'<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;and '-count' attributes).<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#<bang>" name="&lt;bang&gt;">&lt;bang&gt;</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="Special">&lt;bang&gt;</span>&nbsp;&nbsp;(See the '-bang' attribute) Expands to a ! if the<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;command was executed with a ! modifier, otherwise<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;expands to nothing.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#<mods>" name="&lt;mods&gt;">&lt;mods&gt;</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="Special">&lt;mods&gt;</span>&nbsp;&nbsp;The command modifiers, if specified. Otherwise, expands to<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nothing. Supported modifiers are&nbsp;<a class="Identifier" href="windows.html#:aboveleft">:aboveleft</a>,&nbsp;<a class="Identifier" href="windows.html#:belowright">:belowright</a>,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="windows.html#:botright">:botright</a>,&nbsp;<a class="Identifier" href="editing.html#:browse">:browse</a>,&nbsp;<a class="Identifier" href="editing.html#:confirm">:confirm</a>,&nbsp;<a class="Identifier" href="windows.html#:hide">:hide</a>,&nbsp;<a class="Identifier" href="editing.html#:keepalt">:keepalt</a>,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="motion.html#:keepjumps">:keepjumps</a>,&nbsp;<a class="Identifier" href="motion.html#:keepmarks">:keepmarks</a>,&nbsp;<a class="Identifier" href="cmdline.html#:keeppatterns">:keeppatterns</a>,&nbsp;<a class="Identifier" href="windows.html#:leftabove">:leftabove</a>,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="motion.html#:lockmarks">:lockmarks</a>,&nbsp;<a class="Identifier" href="recover.html#:noswapfile">:noswapfile</a>&nbsp;<a class="Identifier" href="windows.html#:rightbelow">:rightbelow</a>,&nbsp;<a class="Identifier" href="various.html#:silent">:silent</a>,&nbsp;<a class="Identifier" href="tabpage.html#:tab">:tab</a>,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="windows.html#:topleft">:topleft</a>,&nbsp;<a class="Identifier" href="various.html#:verbose">:verbose</a>, and&nbsp;<a class="Identifier" href="windows.html#:vertical">:vertical</a>.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="Todo">Note</span>&nbsp;that these are not yet supported:&nbsp;<a class="Identifier" href="autocmd.html#:noautocmd">:noautocmd</a>,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Identifier" href="eval.html#:sandbox">:sandbox</a>&nbsp;and&nbsp;<a class="Identifier" href="various.html#:unsilent">:unsilent</a>.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Examples:<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;command! -nargs=+ -complete=file MyEdit<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\ for f in expand(&lt;q-args&gt;, 0, 1) |<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\ exe '&lt;mods&gt; split ' . f |<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\ endfor</div>
<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function! SpecialEdit(files, mods)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for f in expand(a:files, 0, 1)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exe a:mods . ' split ' . f<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;endfor<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;endfunction<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;command! -nargs=+ -complete=file Sedit<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\ call SpecialEdit(&lt;q-args&gt;, &lt;q-mods&gt;)</div>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#<reg>" name="&lt;reg&gt;">&lt;reg&gt;</a>&nbsp;<a class="Constant" href="map.html#<register>" name="&lt;register&gt;">&lt;register&gt;</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="Special">&lt;reg&gt;</span>&nbsp;&nbsp; (See the '-register' attribute) The optional register,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if specified.&nbsp;&nbsp;Otherwise, expands to nothing.&nbsp;&nbsp;<span class="Special">&lt;register&gt;</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;is a synonym for this.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#<args>" name="&lt;args&gt;">&lt;args&gt;</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="Special">&lt;args&gt;</span>&nbsp;&nbsp;The command arguments, exactly as supplied (but as<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;noted above, any count or register can consume some<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;of the arguments, which are then not part of&nbsp;<span class="Special">&lt;args&gt;</span>).<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="Special">&lt;lt&gt;</span>&nbsp;&nbsp;&nbsp;&nbsp;A single '&lt;' (Less-Than) character.&nbsp;&nbsp;This is needed if you<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;want to get a literal copy of one of these escape sequences<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;into the expansion - for example, to get&nbsp;<span class="Special">&lt;bang&gt;</span>, use<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="Special">&lt;lt&gt;</span>bang&gt;.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#<q-args>" name="&lt;q-args&gt;">&lt;q-args&gt;</a><br>
If the first two characters of an escape sequence are &quot;q-&quot; (for example,<br>
<span class="Special">&lt;q-args&gt;</span>) then the value is quoted in such a way as to make it a valid value<br>
for use in an expression.&nbsp;&nbsp;This uses the argument as one single value.<br>
When there is no argument&nbsp;<span class="Special">&lt;q-args&gt;</span>&nbsp;is an empty string.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Constant" href="map.html#<f-args>" name="&lt;f-args&gt;">&lt;f-args&gt;</a><br>
To allow commands to pass their arguments on to a user-defined function, there<br>
is a special form&nbsp;<span class="Special">&lt;f-args&gt;</span>&nbsp;(&quot;function args&quot;).&nbsp;&nbsp;This splits the command<br>
arguments at spaces and tabs, quotes each argument individually, and the<br>
<span class="Special">&lt;f-args&gt;</span>&nbsp;sequence is replaced by the comma-separated list of quoted arguments.<br>
See the Mycmd example below.&nbsp;&nbsp;If no arguments are given&nbsp;<span class="Special">&lt;f-args&gt;</span>&nbsp;is removed.<br>
&nbsp;&nbsp; To embed whitespace into an argument of&nbsp;<span class="Special">&lt;f-args&gt;</span>, prepend a backslash.<br>
<span class="Special">&lt;f-args&gt;</span>&nbsp;replaces every pair of backslashes (\\) with one backslash.&nbsp;&nbsp;A<br>
backslash followed by a character other than white space or a backslash<br>
remains unmodified.&nbsp;&nbsp;Overview:<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="PreProc">command&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;f-args&gt;</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;XX ab&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="MissingTag">'ab'</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;XX a\b&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'a\b'<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;XX a\ b&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'a b'<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;XX a\&nbsp;&nbsp;b&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'a ', 'b'<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;XX a\\b&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'a\b'<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;XX a\\ b&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'a\', 'b'<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;XX a\\\b&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'a\\b'<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;XX a\\\ b&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'a\ b'<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;XX a\\\\b&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'a\\b'<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;XX a\\\\ b&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'a\\', 'b'<br>
<br>
Examples<br>
<br>
<div class="helpExample">&nbsp;&nbsp; &quot; Delete everything after here to the end<br>
&nbsp;&nbsp; :com Ddel +,$d</div>
<br>
<div class="helpExample">&nbsp;&nbsp; &quot; Rename the current buffer<br>
&nbsp;&nbsp; :com -nargs=1 -bang -complete=file Ren f &lt;args&gt;|w&lt;bang&gt;</div>
<br>
<div class="helpExample">&nbsp;&nbsp; &quot; Replace a range with the contents of a file<br>
&nbsp;&nbsp; &quot; (Enter this all as one line)<br>
&nbsp;&nbsp; :com -range -nargs=1 -complete=file<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Replace &lt;line1&gt;-pu_|&lt;line1&gt;,&lt;line2&gt;d|r &lt;args&gt;|&lt;line1&gt;d</div>
<br>
<div class="helpExample">&nbsp;&nbsp; &quot; Count the number of lines in the range<br>
&nbsp;&nbsp; :com! -range -nargs=0 Lines&nbsp;&nbsp;echo &lt;line2&gt; - &lt;line1&gt; + 1 &quot;lines&quot;</div>
<br>
<div class="helpExample">&nbsp;&nbsp; &quot; Call a user function (example of &lt;f-args&gt;)<br>
&nbsp;&nbsp; :com -nargs=* Mycmd call Myfunc(&lt;f-args&gt;)</div>
<br>
When executed as:<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:Mycmd arg1 arg2</div>
This will invoke:<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:call Myfunc(&quot;arg1&quot;,&quot;arg2&quot;)</div>
<br>
<div class="helpExample">&nbsp;&nbsp; :&quot; A more substantial example<br>
&nbsp;&nbsp; :function Allargs(command)<br>
&nbsp;&nbsp; :&nbsp;&nbsp; let i = 0<br>
&nbsp;&nbsp; :&nbsp;&nbsp; while i &lt; argc()<br>
&nbsp;&nbsp; :&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if filereadable(argv(i))<br>
&nbsp;&nbsp; :&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; execute &quot;e &quot; . argv(i)<br>
&nbsp;&nbsp; :&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; execute a:command<br>
&nbsp;&nbsp; :&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;endif<br>
&nbsp;&nbsp; :&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;let i = i + 1<br>
&nbsp;&nbsp; :&nbsp;&nbsp; endwhile<br>
&nbsp;&nbsp; :endfunction<br>
&nbsp;&nbsp; :command -nargs=+ -complete=command Allargs call Allargs(&lt;q-args&gt;)</div>
<br>
The command Allargs takes any Vim command(s) as argument and executes it on all<br>
files in the argument list.&nbsp;&nbsp;Usage example (<span class="Todo">note</span>&nbsp;use of the &quot;e&quot; flag to ignore<br>
errors and the &quot;update&quot; command to write modified buffers):<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:Allargs %s/foo/bar/ge|update</div>
This will invoke:<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:call Allargs(&quot;%s/foo/bar/ge|update&quot;)</div>
<br>
When defining a user command in a script, it will be able to call functions<br>
local to the script and use mappings local to the script.&nbsp;&nbsp;When the user<br>
invokes the user command, it will run in the context of the script it was<br>
defined in.&nbsp;&nbsp;This matters if&nbsp;<a class="Identifier" href="map.html#<SID>">&lt;SID&gt;</a>&nbsp;is used in a command.<br>
<br>
&nbsp;vim:tw=78:ts=8:ft=help:norl:<br>
</div>

</article>

<footer>
<a href="#top">Return to the top</a> - <a href="index.html">Return to main</a>
<span class="EnglishJapaneseLink">
  <span class="CurrentLanguage">English</span>
</span>
<br />
<div style="text-align:right;">
Hosted by <a href="https://github.com/vim-jp/vimdoc-en">vimdoc-en project</a><br />
If you met any problem, please report it to <a href="https://github.com/vim-jp/vimdoc-en/issues">issue</a>.<br />
</div>
</footer>

<!--<script src="js/check-referrer.js" type="text/javascript"></script>-->

</body>
</html>
<!-- vim:set ts=8 sts=2 sw=2 tw=0 et: -->
